简体   繁体   中英

Determine whether to use internal or external android app

Ive been reading up on where to store my files, and I am still not sure what route I should take. I am writing an application that will store images and pdf's (totaling 300MB or so). I would like the app installed on the internal storage, and then allow the user to store the pdfs and some images on there choice of storage. Is it possible to allow the user to choose which storage they use for those files only even I have this in my manifest:

android:installLocation="internalOnly" 

Essentially I would like to have the user choose this when the applications start.

If it is, would I just need to have a flag in application that if the user chose external and if the external storage was available, had enough space, then save files to it. Every time the user opened the app I would check to make sure the files are available. If the users chose internal it would use openFileOutput. Does this all seem right, is this possible?

Or should I just consider making it completely internal only, because without these PDF's and images the app is not usable.

It sounds like you can set the installLocation as following to accomplish exactly what you want:

android:installLocation="preferExternal"

From the documentation:

If you declare "preferExternal", you request that your application be installed on the external storage, but the system does not guarantee that your application will be installed on the external storage. If the external storage is full, the system will install it on the internal storage. The user can also move your application between the two locations.

If you set it to internalOnly, the user cannot move the application from internal storage to external storage, so above solution is probably your best option.

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