Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Managing media using the Android MediaStore

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.

like image 964
hpique Avatar asked May 01 '10 23:05

hpique


1 Answers

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)

like image 63
Brian Avatar answered Oct 02 '22 07:10

Brian