Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.app.Activity;

import android.database.Cursor;

import android.net.Uri;
import android.provider.MediaStore;

public class Main {
    public static String getRealImagePath(Activity activity, Uri uriPath) {
        String[] proj = { MediaStore.Images.Media.DATA };
        Cursor cursor = activity.getContentResolver().query(uriPath, proj, null, null, null);
        int index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();
        String path = cursor.getString(index);
        // path = path.substring(5);
        return path;
    }
}