protected static String getResource ( Uri uri ) { if ( ! isAPIUri ( uri ) ) { return null ; } String scheme = uri . getScheme ( ) ; String apiScheme = getBaseUri ( ) . getScheme ( ) ; // Strip out the protocol and store the result in the "remainder" variable String remainder = uri . toString ( ) . substring ( scheme . length ( ) ) ; // Strip out the protocol from the base URI String apiRemainder = getBaseUri ( ) . toString ( ) . substring ( apiScheme . length ( ) ) ; // Check that the remainder starts with the apiRemainder if ( ! remainder . startsWith ( apiRemainder ) ) { return null ; } // Return the path, stripped out of the base uri's path return uri . getPath ( ) . substring ( getBaseUri ( ) . getPath ( ) . length ( ) ) ; }
Extracts the resource path from a Uri .