Folder location for images in android app - android

I am creating an app, the purpose of the app is for you to import copies of photos from your phones gallery and associate info against the photo, such as a description, notes etc.
The info will be stored a a dB with paths to the files. Within the app the user can select different photos, where you'll be taken to a new screen that shows the photo and the saved info below it.
I am unsure what is the best place to store the images on the device. Internal storage or external public storage. The downside of internal would be all images are lost when the app is uninstalled, I'm no sure if a user would expect their photos to be deleted on uninstall? That could make a user very upset if they are important photos to them.
Android seem to be pushing you to store data with the apps own sandbox which is deleted on uninstall with Android 11.
Any advice or thoughts?

Related

Android Security concerns saving contents in internal storage(storage/emulated/0)

I was fiddling around with react-native-fs so that users can upload and save images in my app.
I was trying to save images in phone's internal storage, located in '/storage/emulated/0/MyApp', like many other apps do
Using RNFS.readDir('/storage/emulated/0'), I can seem to read the list of all the directories and files here made by other apps also, like personal images and files that I have accessed/downloaded in big apps like telegram, instagram, etc.(e.g. I can access /storage/emulated/0/Telegram/Telegram Images from my app)
Isn't this dangerous? this means that if I wanted to, I can move or upload files(of other apps) of users who are using my app or vice versa, third-party apps can access my private files?
Or am I understanding this wrong?

How to add new content to my flutter app on the fly?

My flutter app provides some content (mostly text and graphics, like blog posts, or news) to its users. These contents need to be updated daily. So there will be new texts, images, maybe even videos. Now, the app would be used even when offline, so all the updated contents should be stored somewhere to be accessed later.
Right now, I'm using a SQLite DB to store texts
The images are stored in the Assets folder of the app.
The nature of the program is such that the users won't want to give the app any SD-Card access permission.
So my question is, how can I update the content without updating the whole app or using any SDcard permissions?
Is it possible to write code that downloads the new content and saves them directly in the Assets folder of the app? Can the app then use the files? without them being referenced in "pubspec.YAML" file?
Can I store all the data (even images and videos which are added daily) in my SQLite DB which is located in phone memory?
What is the standard practice for apps that have this kind of content?
You have to use the storage somehow.
In Android, you don't have to ask for storage permission if you want to save data in internal directory for your app which is storage/emulated/0/Android/data/data/your_package_name/ folder. You can try that.
However it has got a downside, if your app is deleted then all the data will also be deleted.

How to pack app photos with apk?

I am developing an app and I want the photos used in this app to be packed with the apk. The problem is that these photos are downloaded first time when I create the database. In the database I store only location (for example City: Name | Population | Photo Location). Everything works fine but the big problem is that I don't want these downloads to be made at install (it takes 10 minutes because there are a lot of photos), I want to have these photos available at install and be packed with the apk (like the database from assets).
I saw this: Saving and Reading Bitmaps/Images from Internal memory in Android
And currently my photos have been downloaded and are in the /data/user/MY_PACKAGE/imageDir. I don't have any permissions to copy the photos from this folder and if I uninstall the app the photos will be deleted too. And this is not good, I will download the photos with Java and place them manually somewhere, but I don't know where.
My question is where should the photos be placed to have access to them when using the app? And how can I make them download in that folder, without the need of moving the manually?

How to Store Android Pictures to Prevent User Deletion but Still Give User Access

I'm working on my first real Android application, and I have run into a use case problem for which I cannot seem to find a best practice. The application has a main screen with a RecyclerView that has an ImageView as part of the view that makes up the individual list items. Clicking on an item in the RecyclerView takes you to an Activity with a ViewPager giving details for the selected item and allowing the user to swipe through the details of the items that were displayed in the RecyclerView. As part of the workflow of adding or editing an item, the user can take a picture that is used for generating the thumbnail for the RecyclerView and for display in the details fragment in the ViewPager. I plan to provide the ability for the user to share the detail entry, including the picture, on social media or email or to their Google Photos. My dilema is how the picture should be stored on the user's device. You can store to the public external storage, which is scanned by the media scanner and can be accessed by the user for copying to their computer or sharing.
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), albumName);
However, the user can also delete the pictures stored there which poses a problem for generating thumbnails and display in the detail fragment.
Another approach would be to store the pictures to the applications internal storage, like so:
File file = new File(getExternalFilesDir(null), "DemoFile.jpg");
Of course, this would protect the pictures from being deleted. However, the user would not be able to access that storage location from their computer or from other photo apps on their device.
I could store a copy in both locations. However, that seems like a waste of device space. Are there any best practices for such a use case? Do others have any experience with this scenario that they would be willing to share?
The best approach would be, to upload the picture the User takes to a server via a small .php script, so it is guranteed, that the user cannot simply delete the picture and causing your app to malfunction, while still giving the user the ability to have a local copy of the image(s) on their device.
You could place an empty .nomedia file in the folder of your thumbnails. This will prevent the media scanner from scanning what's inside.
That being said, if you'd like to get these thumbnails automatically deleted when your app gets uninstalled, which I think is what you'd want, you can create a private directory on your external storage that will be tied to your particular application.
By the way, in Android the user is the application itself, so by making a directory private, you're making it private for the application itself (not the actual user of the device). But obviously, if you're saving these thumbnails on a removable sdcard, or if the actual user roots his device, these files won't truly be private.

Distribute air apps without recompiling

I'm developing an air image viewing application for Windows and Android that will allow some special users to import bitmaps to it. The user can click on a button, browse to a bitmap stored locally and then the app saves the image to the documentsDirectory.
Later on, other users (let's call then common users) will get this already compiled app and view the images imported by the special users.
My question is how can I make the app save the images within it without recompiling it?
Any ideas are welcome! Thank you all!
The only option I can think of, is to make a web server to store and load the images by those users. That's because the images will be stored in the documents or cache directory of the device which means that there is no automatic way to bring them to other devices.
You need a web server that the images will be uploaded and saved, and later on retrieved by other clients. It's called centralized assets system.

Categories

Resources