Home MediaStore External Content URI is fetching data from SDCARD
Reply: 0

MediaStore External Content URI is fetching data from SDCARD

user1439
1#
user1439 Published in April 23, 2018, 9:19 am

I am using MediaStore and Cursor to fetch audio files from a specified folder. What I want is that, it should fetch the list of songs from the phone's internal storage but it is fetching from SDCARD. Although I have tried using INTERNAL_CONTENT_URI but it is not getting anything at all. Kindly have a look, what's wrong in it. Any help will be appreciated.

    String AudioFilePath = "%" +"/nexcox/voicerecorder/audio/" +"%";

    Uri uri= MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
    String selection= MediaStore.Audio.Media.DATA +" LIKE ? ";
    Cursor cursor=context.getContentResolver().query(uri,null,selection,
            new String[]{AudioFilePath},
            null);


    if (cursor!=null){
        if (cursor.moveToFirst()){
            do {
                String name = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
                String duration = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DURATION));
                String sourceLocation = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DATA));

                AudioInfo audioInfo=new AudioInfo(name,duration,sourceLocation);
                audioInfos.add(audioInfo);
            }while (cursor.moveToNext());
        }

        cursor.close();
        audioAdapter=new AudioAdapter(context,audioInfos);

        recyclerView.setAdapter(audioAdapter);
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.518871 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO