简体   繁体   中英

is this the best storage option for me?

I want to save downloaded images from a server. I want these images to be accessible only from within the application itself. I don't want the images accessible from anywhere else, ie someone can just delete/modify it like if it was on the SD card or from another different application. I'm thinking it would be best if I were to use internal storage, as it is private to my app.

http://developer.android.com/guide/topics/data/data-storage.html#filesInternal

are there better options out there?

Internal storage is the best option if you want to keep your files private.

However, on most devices, internal storage is very limited and the users might uninstall your app if you use too much of it (images can be pretty big).

You should look into using the external storage to save images, and possibly encrypting them if you really want to keep them private.

As already mentioned by Raghav this would be a good option, and as said the internal storage is very limited (mostly on older devices), however if you are on a rooted device it will be possible to delete your files anyway. Take into account the limited storage, as people is also making "swap partitions" on their SD cards because internal storage is very limited.

This is is the simplest solution. The other typical solution is to store the image as a blob in the application's database. This will make it completely inaccessable outside of your application. You can do it using the method shown here:

How to store and retrieve a byte array (image data) to and from a SQLite database?

The draw back to this is the relatively small memory space you will be given for your DB (<60MB), so this only works if you have a small number of images.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM