get Last Recorded Video Uri - Android Media

Android examples for Media:Video

Description

get Last Recorded Video Uri

Demo Code


import android.app.Activity;
import android.content.CursorLoader;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;

public class Main {
  public static Uri getLastRecordedVideoUri(Activity activity) {
    String[] proj = { MediaStore.Video.Media._ID };
    Uri contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
    String sortOrder = MediaStore.Video.VideoColumns.DATE_TAKEN + " DESC";
    CursorLoader loader = new CursorLoader(activity, contentUri, proj, null, null, sortOrder);
    Cursor cursor = loader.loadInBackground();
    cursor.moveToFirst();//from   www .  j  av  a 2  s .c o m

    return Uri.parse(contentUri.toString() + "/" + cursor.getLong(0));
  }
}

Related Tutorials