RTEditor/src/main/java/com/onegravity/rteditor/media/MediaUtils.java
public static String determineOriginalFile(Context context, Uri uri) throws IllegalArgumentException {
        String originalFile = null;

        if (uri != null) {
            // Picasa on Android >= 3.0 or other files using content providers
            if (uri.getScheme().startsWith("content")) {
                originalFile = getPathFromUri(context, uri);
            }

            // Picasa on Android < 3.0
            if (uri.toString().matches("https?://\\w+\\.googleusercontent\\.com/.+")) {
                originalFile = uri.toString();
            }

            // local storage
            if (uri.getScheme().startsWith("file")) {
                originalFile = uri.toString().substring(7);
            }

            if (isNullOrEmpty(originalFile)) {
                throw new IllegalArgumentException("File path was null");
            }
        } else {
            throw new IllegalArgumentException("Image Uri was null!");
        }

        return originalFile;
    }
public static String determineOriginalFile(Context context, Uri uri) throws IllegalArgumentException {
        String originalFile = null;

        if (uri != null) {
            // Picasa on Android >= 3.0 or other files using content providers
            if (uri.getScheme().startsWith("content")) {
                originalFile = getPathFromUri(context, uri);
            }

            // Picasa on Android < 3.0
            if (uri.toString().matches("https?://\\w+\\.googleusercontent\\.com/.+")) {
                originalFile = uri.toString();
            }

            // local storage
            if (uri.getScheme().startsWith("file")) {
                originalFile = uri.toString().substring(7);
            }

            if (isNullOrEmpty(originalFile)) {
                throw new IllegalArgumentException("File path was null");
            }
        } else {
            throw new IllegalArgumentException("Image Uri was null!");
        }

        return originalFile;
    }
public static String determineOriginalFile ( Context context , Uri uri ) throws IllegalArgumentException { String originalFile = null ; if ( uri != null ) { // Picasa on Android >= 3.0 or other files using content providers if ( uri . getScheme ( ) . startsWith ( "content" ) ) { originalFile = getPathFromUri ( context , uri ) ; } // Picasa on Android < 3.0 if ( uri . toString ( ) . matches ( "https?://\\w+\\.googleusercontent\\.com/.+" ) ) { originalFile = uri . toString ( ) ; } // local storage if ( uri . getScheme ( ) . startsWith ( "file" ) ) { originalFile = uri . toString ( ) . substring ( 7 ) ; } if ( isNullOrEmpty ( originalFile ) ) { throw new IllegalArgumentException ( "File path was null" ) ; } } else { throw new IllegalArgumentException ( "Image Uri was null!" ) ; } return originalFile ; }
Retrieve local file path for an arbitrary Uri

@throws IllegalArgumentException If the uri is null or we can't resolve the uri to an absolute file path
(meaning the uri isn't valid)
Retrieve local file path for an arbitrary Uri