这个方法是从网上找到的,感谢网友的无私奉献!

 

 1     public static String getFilePathFromUri(Context context, Uri uri,
 2             String[] projection, String selection, String[] selectionArgs,
 3             String sortOrder) {
 4         Cursor cursor = context.getContentResolver().query(uri, projection,
 5                 selection, selectionArgs, sortOrder);
 6         int index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
 7         cursor.moveToFirst();
 8         String path = cursor.getString(index);
 9         cursor.close();
10         cursor = null;
11         return path;
12     }

 

 

相关文章:

  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-08-29
  • 2021-07-31
猜你喜欢
  • 2022-01-16
  • 2021-08-28
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案