idunnololz idunnololz - 1 year ago 130
Android Question

Android: Is EXTERNAL_CONTENT_URI enough for a photo gallery?

I'm playing around with Android's MediaStore classes and was attempting to create a very simple photo gallery app when I noticed that were two image content URIs: EXTERNAL_CONTENT_URI and INTERNAL_CONTENT_URI. At first I thought it was referring to the location of storage (external SD or internal memory) but after a bit of testing this was clearly not the case. I read more about it here, and it seemed to indicate that the internal content uri is actually content that are internal to each of the apps on the device. However I am not entirely sure and wanted opinions from more experienced developers who are more familiar with the MediaStore classes.

So my main question is, would just querying the EXTERNAL_CONTENT_URI be enough to get all of the important photos? And if possible to answer, what exactly is the INTERNAL_CONTENT_URI and what is it supposed to be used for?

Answer Source

External vs Internal storage doesn't refer to the location of the memory, but the privacy policy regarding it. Internal storage means only the app or system/super user processes can access the contents.

External storage can be read by every app, it's what appears when you plug in your phone to your computer, so you can think of it as what is shown to everyone else, hence "external."

I have a Samsung S5 for instance, and it puts both internal and external storage on the same 'internal' flash memory, they are in fact just separate partitions on the same stick of ram.

When I add a SD card, it adds another (secondary) external storage location.

Every android device must ship with internal and external storage, so devices that ship without an SD Card for instance are guaranteed to have partitioned 'internal' memory, for internal and external storage.

As for how the External_Content_URI relates, it will return images that are located in external storage -- reading the docs more closely, it says it returns only for the "primary" external storage volume. I just noticed that last part in quotes myself, so it's something I'll test in the next few days if secondary external storage is also indexed or retrieved by the mediastore, if someone else doesn't help answer that first.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download