开发者

Organizing files on sdcard into directories

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开发者_StackOverflow社区 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;

Thanks!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜