All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.vudroid.core.utils.PathFromUri Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
package org.vudroid.core.utils;

import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;

public class PathFromUri
{
    public static String retrieve(ContentResolver resolver, Uri uri)
    {
        if (uri.getScheme().equals("file"))
        {
            return uri.getPath();
        }
        final Cursor cursor = resolver.query(uri, new String[]{"_data"}, null, null, null);
        if (cursor.moveToFirst())
        {
            return cursor.getString(0);
        }
        throw new RuntimeException("Can't retrieve path from uri: " + uri.toString());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy