Construct MediaStore URI for specific folder

后端 未结 3 2106
你的背包
你的背包 2020-12-11 07:45

For example if 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

相关标签:
3条回答
  • 2020-12-11 08:21

    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 ;-)

    0 讨论(0)
  • 2020-12-11 08:22
    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.

    0 讨论(0)
  • 2020-12-11 08:26

    Do exactly this,

    Cursor mCursor = getContentResolver().query(uri1, Selection, 
                android.provider.MediaStore.Audio.Media.DATA + " like ? ", 
                new String[] {str},
                null);
    
    0 讨论(0)
提交回复
热议问题