0

I want to write file using uri.

OutputStream output = context.getContentResolver().openOutputStream(uri);

But it returns error.

java.io.FileNotFoundException: Missing file for 0E47-495B:Download/8324.jpg.xdec at /storage/external_SD/Download/8324.jpg.xdec

If I manually create empty file, OutputStream writes stuff. I need to create empty file programmatically with uri before stream opening.

Daimonium
  • 29
  • 8
  • Did you provide permission in manifest? and also did you checked Runtime permissions – Rahul Jan 24 '17 at 08:23
  • Yes, I added ` ` – Daimonium Jan 24 '17 at 08:26
  • Did you checked RunTime permissions? – Rahul Jan 24 '17 at 08:27
  • What do you mean? – Daimonium Jan 24 '17 at 08:29
  • This might help you - https://inthecheesefactory.com/blog/things-you-need-to-know-about-android-m-permission-developer-edition/en – Rahul Jan 24 '17 at 08:29
  • I use it with Lollipop. There is no runtime permissions. – Daimonium Jan 24 '17 at 08:34
  • please check this http://stackoverflow.com/questions/2975197/convert-file-uri-to-file-in-android – Mina Fawzy Jan 24 '17 at 08:41
  • I already checked this. Main part of answers doesn't work. Other doesn't support external_SD recognition. Please, don't suggest uri to absolute path conversion. – Daimonium Jan 24 '17 at 08:47
  • Please show the value of `uri.getPath()` and `uri.toString()`. And tell us where you get the uri from. Put all in your post please. You should have started your post with this info. – greenapps Jan 24 '17 at 08:55
  • getPath() returns null, as mentioned in comments (link above). – Daimonium Jan 24 '17 at 08:58
  • I see no null and i do not follow links. Please give all info i asked for. You should really better show what you are doing. – greenapps Jan 24 '17 at 09:01
  • Please, check this code to understand why your method won't work on real Android device. http://stackoverflow.com/a/41520090/6468311 Note that this code doesn't support external SD. But I found already the way to add support of external storages. It's not simple. Question is still opened. Just because interesting. – Daimonium Jan 24 '17 at 12:36

0 Answers0