Android - MediaStore.Video.query() is returning null

后端 未结 2 2081
南笙
南笙 2020-12-18 04:52

I\'m trying to retrieve the metadata from a video file (title, language, artist) using the method MediaStore.Video.query(). However, the method is always returning null. The

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-18 05:11

    I updated your code, it works, just check it

    public static void dumpVideos(Context context) {
    Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
    String[] projection = { MediaStore.Video.VideoColumns.DATA };
    Cursor c = context.getContentResolver().query(uri, projection, null, null, null);
    int vidsCount = 0;
    if (c != null) {
        c.moveToFirst();
        vidsCount = c.getCount();
        do {
            Log.d("VIDEO", c.getString(0));
        }while (c.moveToNext());
        c.close();
    }
    Log.d("VIDEO", "Total count of videos: " + vidsCount);
    }
    

提交回复
热议问题