获取特定Mp3文件的信息

时间:2014-07-09 19:53:33

标签: android

我正在尝试从此处获取特定Mp3文件的信息,代码但每次返回Null:

 ContentResolver musicResolver = getMainActivity.getContentResolver();
 Cursor musicCursor = musicResolver.query(Uri.parse("/storage/sdcard/LifeMatePrivate  
 /SingleChatFiles/admin/01 - Buddha For Mary.mp3"),null, null, null, null);
 //iterate over results if valid
 if(musicCursor!=null && musicCursor.moveToFirst()){
    //get columns
    int titleColumn = musicCursor.getColumnIndex
            (android.provider.MediaStore.Audio.Media.TITLE);
    int idColumn = musicCursor.getColumnIndex
            (android.provider.MediaStore.Audio.Media._ID);
    int artistColumn = musicCursor.getColumnIndex
            (android.provider.MediaStore.Audio.Media.ARTIST);
    //add songs to list
    do {
        long thisId = musicCursor.getLong(idColumn);
        String thisTitle = musicCursor.getString(titleColumn);
        String thisArtist = musicCursor.getString(artistColumn);
        System.out.println("ID:"+thisId+" Title:"+thisTitle+" Artist:"+thisArtist);
    } 
    while (musicCursor.moveToNext());
 }
我正在做一些错误的人吗?

0 个答案:

没有答案