Take the 2-minute tour ×

I have images uploaded on the simulated sdcard on my emulator. I downloaded them from the browser, using the long-click on each image.

When I look at the file explorer in the DDMS perspective, I see that they are in the directory sdcard/download.

Now if I want to download some audio files and use them in an app to, say list the title of all audio files, will they go in the same directory? (I am trying to push the audio files manually from my computer to the emulator).

This doesn't seem right. Shouldn't the media files of different types (pictures, audio, video) go into different directories?

Also, thinking this through a little, how is something like this related to the physical directory on the sdcard?

 Uri mMedia = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;


share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

The correct way to access media content is via the media content providers on the device.

Content providers make it easy to access data in a unified way, whether that data is stored on disk (i.e. /sdcard/...) or in something like a SQLite database. Content providers generally expose data using a custom Android-specific content:// URI scheme.

To query content living at a given content URI (such as MediaStore.Images.Media.EXTERNAL_CONTENT_URI), use the ContentResolver class. Examples on how to use this class can be found all throughout the SDK samples and Android Open Source Project (gitweb).

Also look at the MediaScannerConnection class for information on triggering media scanning (which populates the media content providers), etc.

share|improve this answer
Roman, thanks for taking the time to answer. I have been using the Content Provider APIs that you refer to from my code (except for MediaScannerConnection - I'll look it up). However, to test the code, I have to have some media downloaded on the sdcard of the emulator. My question was, how to physically store the files in sdcard... i.e. which directories to put audio/picture/vedio files in. Do I just push all files into /sdcard directory, or do I organize them into separate directories? And if the latter, then how? –  OceanBlue May 28 '10 at 14:15
The media scanner will go through the entire SD card looking for media, so you're free to place it in any directory structure that makes sense to your app and that would make sense to the user shall they mount the card on their computer. –  Roman Nurik May 28 '10 at 16:38
add comment

Your Answer


