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

MediaStore External Content URI is fetching data from SDCARD

user6840 Published in September 19, 2018, 9:07 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},

    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);
            }while (cursor.moveToNext());

        audioAdapter=new AudioAdapter(context,audioInfos);

share|improve this question
  • You will get data from the Media database which holds all media details, both from internal and external storage. You can test the _DATA column which holds the full path for each entry. – Theo Apr 17 at 9:42
  • Can you be more specific. If you could tell me, what I need to change in the above code to fix the issue. That will be very kind of you. – Khurram Shahzad Apr 17 at 12:42

2 Answers 2

active oldest votes
up vote 0 down vote
You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO