开发者

Construct MediaStore URI for specific folder

For example i开发者_高级运维f a have two directories /sdcard/Music/Music-1 and /sdcard/Music/Music-2 how can I construct a URI to get the files in Music-1 dir for example. I can use MediaStore.Audio.Media.EXTERNAL_CONTENT_URI to get the content of all external storage but how to do the trick only for specific dir.


Cursor mCursor = getContentResolver().query(
                   uri1, Selection, 
                   android.provider.MediaStore.Audio.Media.DATA + " like ? ", 
                   new String[] {str}, null);

You might need to use "%"+str+"%" instead, because "Music-1" is just part of the MediaStore.Audio.Media.DATA.


Filter the path from the DATA field and construct a poper SELECT WHERE statement to match the folder names, you can use SUBSTR in the query ;-)


Do exactly this,

Cursor mCursor = getContentResolver().query(uri1, Selection, 
            android.provider.MediaStore.Audio.Media.DATA + " like ? ", 
            new String[] {str},
            null);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜