Internal or external storage? ... context.getFilesDir () or context.getExternalFilesDir ()?

I read this and this article , but I'm not sure where it is best to store image data from my application.

My application contains a database of products, and when a product is viewed, the image for this product is downloaded from the server and must be stored locally.

Most of the tips seem to use Environment.getExternalStorageDirectory(), but very few posts seem to recommend context.getExternalFilesDir()- even though this may be more suitable for many types of applications (and does not require explicit permission with KitKat).

In any case, the problem with both of these two external storage solutions is that they usually require permission android.permission.WRITE_EXTERNAL_STORAGE, which will probably put off a lot of my potential users.

So, today I discovered context.getFilesDir()for internal storage - which seems ideal for my applications, since it does not require manifest permission, and if the user uninstalls my application, then all the content will be (plus, the content that stores my application stores will not be publicly available), which, I suppose, is a bonus).

The above Android documentation does not warn about usage context.getFilesDir(), so I wonder what are the disadvantages? Clogging the internal storage with the downloaded data is the only thing I can think about - but if it is so that most applications write to the external storage, then if my application also writes to the external storage, then it is not that it is more likely to clog things up ?

So, to summarize, I want to save the downloaded images on the device, really want to avoid adding permissions to access files, I would prefer that other applications could not access my data, but want to solve this "correct" way using the internal storage / context.getFilesDir()Suitable for an account or am I missing something ??

+4

Source: https://habr.com/ru/post/1568785/


All Articles