I have an application that downloads most of the resources from the internet during run time.
Most of those resources are images.
I don't want the user to see those images in the gallery application or in any other application. This requirement is crucial to me since:
I'm tracking which resource was downloaded and which need to be download later.
All those resources would be meaningless to the user and would irritate him.
I don't want the user or any other application to delete those images
Note: I'm aware to the fact that rooted users can do what ever they want and I don't care that those user will mess up the app.
To fulfill those requirements I used the internal storage and it works exactly as I expected and as needed.
I do let the user to move my application to the SD card, But:
what is happening to all the files that I saved in the internal storage and to the DB?
Are they all moving to the SD card with the application? Do they stay in the internal storage?
I believe that they do stay in the internal storage, but I haven't found any documentation for it.
And after I'll understand the behavior it raise few other questions.
The only requirement that I have is that the resources would be downloaded from the internet and that the user won't see them in any other application. I don't really care where those files are being saved, I think that if the user decides to move the application to the SD card it is since he has lack of memory in the internal storage, therefor I should transfer all my resources to the SD card.
Can i save something on the SD card without those files to be public for all?
What is the best way to handle this situations?
What option do I have to handle this situation?
Can I know if the app is installed on the SD card or on the internal storage?
I would thank you all for all your insights and recommendations.
Regarding the images not being visible in the Gallery App, you should put a .nomedia file into the folder that contains your images. Example: image permissions (don't want them in gallery)
Regarding the app to SD feature, I also wanted to have info on the subject, so I cannot help you :)
Useful answer: https://stackoverflow.com/a/3687467/334493
Related
I am making an app where a user can take pictures, but I don't want them to be directly accessible outside the app. The user can choose to send a picture somewhere else if they want, but by default the pictures should be internal to the app only.
What is the correct way to do this? There are so many different path defaults in Android and I am not sure which I should be using (internal memory, external memory, internal cache, external cache, SD Cards, etc).
I am looking at this link here https://developer.android.com/training/basics/data-storage/files.html
It looks like internal storage via getFilesDir() is what I am looking for, correct? However pictures are also large files and I don't know if it makes sense to put them internal to the phone or if this is bad practice.
Per the Forget the Storage Permission talk, getFilesDir() is indeed the right location for private storage of user data.
My app needs to download and save a big number of images and mp3s.
These will make sense only for the app, only my app will be able to use them in an meaningful way. The user or other apps won't know what to do with them.
Where should I keep them, in external or internal storage?
I'd like to keep them in internal memory because they are only meaningful to the app, and they will be wiped out when the app is deleted.
However, for old devices the internal memory is very limited, and I think it would be a hassle for the user to keep these files here.
So, I was thinking about external memory, but I don't like the idea of keeping those files there after the app has been deleted.
What would be the best practice for this?
Thank you.
Use the path returned by 'getExternalFilesDir(String type)'
From the documentation:
"Returns the absolute path to the directory on the primary external filesystem (that is somewhere on Environment.getExternalStorageDirectory()) where the application can place persistent files it owns. These files are internal to the applications, and not typically visible to the user as media.
This is like getFilesDir() in that these files will be deleted when the application is uninstalled, however there are some important differences:
External files are not always available: they will disappear if the user mounts the external storage on a computer or removes it. See the APIs on Environment for information in the storage state.There is no security enforced with these files. For example, any application holding WRITE_EXTERNAL_STORAGE can write to these files."
For further details: http://developer.android.com/reference/android/content/Context.html#getExternalFilesDir(java.lang.String)
So yes, you can use external storage and have the files deleted when the app is uninstalled (as long as you are happy with the lack of security).
This is pretty close to an opinion question and will likely get closed.
Short answer: Use external storage. Users will get mad if you're filling up their internal storage with tons of files.
Recommendation: Give the users a toggle option to store it wherever they want!
I don't want the SD Card to be removed by user when my application is running, as it will contain the database I would be using in my application for displaying images and information from it.
Possible solutions as I see can be to copy the contents of the Database in SD card into the application at the start of the application (but it might consume time).
Is there any particular way by which I can freeze my application when the SD-Card is removed ?
Thanks for your help in advance !
Cheers,
Sumit
How about don't have the database on the SD card in the first place? If you are downloading it, download it directly to internal storage. If it is inside the APK as an asset or resource, extract it to internal storage.
If you need to use external storage (SD card), check if external storage is mounted when the app starts. If it is not, display an appropriate message and finish the activity.
How can I let the user move an app to SD card, but totally?
I've used android:installLocation="auto" in the android manifest, but it seems that it not move the entire app, only a piece.
Can you explain me how to let it move totally?
There is no way you can move app "totally" to the external storage. What you are using is your best possible bet. If your app consumes lot of memory due to data such media content etc or user created media. Write code which uses the external storage to store such data.
There are a few G1 users reporting that my app won't display images. I can only imagine this is because they don't have an SD card.
My app is heavy on images. Is it appropriate to store images on the internal memory? I don't even know if there'd be enough space.
It's not appropriate to store them on the internal memory. What you should do is check for the existence of an SD card and alert the user if they don't have one telling them your app won't work without it. See here for how to check external media availability.
I agree with Felix that internal memory should not be used for cache. But anyway if there are not so much images you can use getCacheDir to store them. http://developer.android.com/reference/android/content/Context.html#getCacheDir().