You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/10/20 17:55:37 UTC

[GitHub] [cordova-plugin-camera] sylber-cz commented on pull request #585: (Android) Fix: File path correction if Uri authority is FileProvider

sylber-cz commented on pull request #585:
URL: https://github.com/apache/cordova-plugin-camera/pull/585#issuecomment-713035616


   Any update on this?
   
   > I fixed with this code:
   > 
   > ```
   > public static String getFilePath(Context context, Uri uri) {
   > 
   >     Cursor cursor = null;
   >     final String[] projection = {
   >       MediaStore.MediaColumns.DISPLAY_NAME
   >     };
   > 
   >     try {
   >       cursor = context.getContentResolver().query(uri, projection, null, null,
   >         null);
   >       if (cursor != null && cursor.moveToFirst()) {
   >         final int index = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DISPLAY_NAME);
   >         return cursor.getString(index);
   >       }
   >     } finally {
   >       if (cursor != null)
   >         cursor.close();
   >     }
   >     return null;
   >   }
   > 
   > ..................
   > 
   >       // DownloadsProvider
   >       else if (isDownloadsDocument(uri)) {
   >         String fileName = getFilePath(context, uri);
   >         if (fileName != null) {
   >           return Environment.getExternalStorageDirectory().toString() + "/Download/" + fileName;
   >         }
   > ........................
   > ```
   Can you share your FileHelper.java file?
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org