Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.app.Activity;

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

public class Main {

    public static String uriToFilePath(Activity context, Uri uri) {
        String[] proj = { MediaStore.Images.Media.DATA };
        Cursor actualimagecursor = context.managedQuery(uri, proj, null, null, null);
        int actualImageColumnIndex = actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        actualimagecursor.moveToFirst();
        String imgPath = actualimagecursor.getString(actualImageColumnIndex);
        return imgPath;
    }
}