Android examples for Media:Video
Get path of video from uri ContentResolver
//package com.java2s; import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore.Video; public class Main { /**//w ww .j a v a 2 s .c om * Get path of video from uri * * @param contentResolver * @param contentURI * @return path of video. Null if not found. */ public static String getRealVideoPathFromURI( ContentResolver contentResolver, Uri contentURI) { Cursor cursor = contentResolver.query(contentURI, null, null, null, null); if (cursor == null) return contentURI.getPath(); else { cursor.moveToFirst(); int idx = cursor.getColumnIndex(Video.VideoColumns.DATA); try { return cursor.getString(idx); } catch (Exception exception) { return null; } } } }