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

MediaStore External Content URI is fetching data from SDCARD

user1439 Published in July 21, 2018, 4:10 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);

You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO