문제

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!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top