package com.test.butt;

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

public class ButtUtils {
    public static String UriToPath(Context context, Uri uri) {
        Cursor cursor = null;
        try {
            String[] data_tag = { MediaStore.Images.Media.DATA };
            cursor = context.getContentResolver().query(uri, data_tag, null, null, null);
            int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            cursor.moveToFirst();
            String filepath = cursor.getString(column_index);
            return filepath;
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }
}
