0

I Use classes from this answer

Stack Answer

and I have problem implementing code which returned me real path from selected image, I need real route for get FILE on other method (for send to server)

But I'm not successful.

I was trying for hours find something on the web but unsuccessful too.

Please do you have some idea?

(I need send image for server so I need File image1 = new File(PathString) )

Community
  • 1
  • 1
user7575308
  • 81
  • 4
  • 12

2 Answers2

0

I need real route for get FILE on other method

Step #1: Use ContentResolver and openInputStream() to get an InputStream on the content represented by the Uri that you received.

Step #2: Create a FileOutputStream on some temporary file that you control (e.g., in getCacheDir()).

Step #3: Copy the content from the InputStream to the FileOutputStream, using standard Java I/O.

Step #4: Use the file that you just created.

Step #5: When you are done with that file, delete it.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • i bet you must be answering that kind of "how to get the real path from my uri" question 10 times a month ;-) – pskink Mar 15 '17 at 19:52
0

My problem solve this code...

here is good everything

solution

user7575308
  • 81
  • 4
  • 12