get Video By Title from Media Store - Android Media

Android examples for Media:Video

Description

get Video By Title from Media Store

Demo Code


//package com.java2s;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;

import android.provider.MediaStore;

public class Main {
    public static Cursor getVideoByTitle(Context context, String title) {
        Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
        String[] columns = { MediaStore.MediaColumns._ID,
                MediaStore.MediaColumns.MIME_TYPE,
                MediaStore.Video.VideoColumns.TITLE,
                MediaStore.Video.VideoColumns.DATA };

        String selection = MediaStore.Video.VideoColumns.TITLE + " LIKE ?";
        String selectionArgs[] = { "%" + title + "%" };

        Cursor cursor = context.getContentResolver().query(uri, columns,
                selection, selectionArgs, null);

        return cursor;
    }//from   w w  w  .ja va2  s .  c o  m
}

Related Tutorials