When you choose a picture from the system and get to their path, you find that some of the images are Uri.getscheme "file", and some of the images are Uri.getscheme "content". All paths that result in Uri.getpath and cannot get all the pictures are resolved with the following code:
public static String GetPath (activity activity, Uri Uri) {l.i ("hui", "path before processing:" + URI); if (null = = URI) {return null;} String path = null; String scheme = Uri.getscheme (), if (scheme = = null) {path = Uri.getpath ();} else if (ContentResolver.SCHEME_FILE.equals (SC heme) {path = Uri.getpath ();} else if (ContentResolver.SCHEME_CONTENT.equals (SCHEME)) {string[] projection = {MediaStor E.images.media.data}; cursor cursor = activity.managedquery (URI, projection, null, null,null); if (null! = cursor) {int column_index = Cursor.get Columnindexorthrow (MediaStore.Images.Media.DATA), Cursor.movetofirst ();p ath = cursor.getstring (column_index); VERSION. Sdk_int <) {//android4.0 and above will automatically close without causing attempted//to access a cursor after it has//been closed exception cursor.close ( );}}} return path;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Get the path of all pictures from the Android album