Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore; public class Main { /** * Get the value of the data column for this Uri. This is useful * for MediaStore Uris, and other file-based ContentProviders. * * @param context The context. * @param uri The Uri to query. * @param selection (Optional) Filter used in the query. * @param selectionArgs (Optional) Selection arguments used in the query. * @return The value of the _data column, which is typically a file path. */ private static String getGhostMySelfieDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) { // Projection used to query Android GhostMySelfie Content Provider. final String[] projection = { MediaStore.Images.Media.DATA }; //Query and get a cursor to Android GhostMySelfie // Content Provider. try (Cursor cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null)) { // If selfie is present, get the file path of the selfie. if (cursor != null && cursor.moveToFirst()) return cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)); } // No selfie present. returns null. return null; } }