0

I am trying to get real path of a content uri from

  1. files-path
  2. cache-path
  3. external-path
  4. external-files-path
  5. external-cache-path

I have tried and achieved some of the above using getRealPath uri file from Internet. Like the following url not able to get actual path but in whatsapp and skype does in all cases. Don't know how to read it. I know many codes available but not possible for all cases.

content://com.skype.raider.fileprovider/SkypeDownload/b959d70-6f3bacda-97-170612153b8.jpg content://com.super.android.provider/external_files/Android/data/com.super.android/cache/data/fka/images/1582183232389.jpg

content://com.app.yoyo.fileprovider/temp/1582131571955.jpg

  • On top of all the problems cited in those duplicates, access to external storage is restricted in Android 10 and workarounds are largely eliminated in Android 11. – CommonsWare Feb 22 '20 at 13:40
  • But in Android 9 also not able to read why?. I can't find any solution for this. Please share any references. – Ganesh Krishnamoorthy Feb 22 '20 at 14:05
  • "But in Android 9 also not able to read why?" -- because a `Uri` is not a file. There is no requirement for a `Uri` to map to a file. This is covered in the duplicate questions. "I can't find any solution for this" -- stop thinking in terms of files. – CommonsWare Feb 22 '20 at 14:07
  • See I used content resolver query and inputstream both are returns null and exception only for the above uri's. – Ganesh Krishnamoorthy Feb 22 '20 at 14:09
  • Please allow to answer some one for my problem because i can't find a proper solution anywhere. – Ganesh Krishnamoorthy Feb 22 '20 at 14:12
  • If you post that code and those stack traces, perhaps we can provide some advice. Bear in mind that [you only have short-term access to the content](https://commonsware.com/blog/2016/08/10/uri-access-lifetime-shorter-than-you-might-think.html). You may also wish to consider reading more about a [mcve]. – CommonsWare Feb 22 '20 at 14:13
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/208317/discussion-between-ganesh-krishnamoorthy-and-commonsware). – Ganesh Krishnamoorthy Feb 22 '20 at 14:13
  • android.os.RemoteException: Remote stack trace: at com.android.server.am.ActivityManagerService.getContentProviderImpl(ActivityManagerService.java:12357) at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:12764) at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:358) at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3377) This exception got when try to get real path and i have used the code at here https://stackoverflow.com/a/39388941/1509734 – Ganesh Krishnamoorthy Feb 22 '20 at 14:23
  • Well, sure. **There is no real path**. Stop trying to get one. Follow the instructions in the duplicate questions. Pass the `Uri` to `openInputStream()` on your `ContentResolver` to get an `InputStream` on the content. – CommonsWare Feb 22 '20 at 14:27
  • Yes I got the above exception because of I used openInputStream() only. You can also face the same issue while share a content from skype your own application. – Ganesh Krishnamoorthy Feb 22 '20 at 14:32
  • 1
    "Yes I got the above exception because of I used openInputStream() only" -- that does not match "This exception got when try to get real path". This is why Stack Overflow asks that developers provide a [mcve], with the complete code and the complete stack trace in the question. – CommonsWare Feb 22 '20 at 14:34
  • @CommonsWare How can I uoload File to multipart file upload without File object? – Abhay Koradiya May 01 '20 at 09:01
  • 1
    @AbhayKoradiya: You could use [this `InputStreamRequestBody`](https://github.com/square/okhttp/issues/3585#issuecomment-327319196) with OkHttp. – CommonsWare May 01 '20 at 11:04

0 Answers0