views:

660

answers:

2

I manage media (images, sound) of my app directly, reading and saving to the SD card. Should I be using the MediaStore instead? I'm not quite sure what the MediaStore is for, and the javadoc is not very helpful.

When should an app use the MediaStore? A brief overview of the pros and cons of the MediaStore will be much appreciated.

+1  A: 

I am no expert in this but as far as my common sense goes, well its the easy way to search for certain types of files.

If your app has a library of sorts, then using MediaStore instead of searching all by yourself is more useful, faster and less power consuming. Also you can be assured that those are all the files present in the system.

I hope this helps.

the100rabh
A: 

As an avid android user.

I think MediaStore is the "Public Link" between the internal Android Media Scanner Application (You can manually invoke it through Spare Parts) and 3rd party applications, like yours.

I'm guessing MediaStore is this "public link" based on its android.provider packaging.

As providers in android, is how applications provide information to other applications

If MediaStore is a ContentProvider, reading information populated by MediaScanner.

Then MediaStore is for User media, such as music, video, pictures etc.

For ringtones, notifications; I think you are supposed to use android.media.RingtoneManager

Also don't hardcode the path "/sdcard/" There is an api call to get it, Environment.getExternalStorageDirectory()

http://twitter.com/cyanogen/status/13980762583

====

The pro is that Media Scanner runs every time you mount the removable storage to the phone, and it also scans the internal memory (if it has any like the HTC EVO & incredible)

Brian