0

I've followed this How to use the new SD card access API presented for Android 5.0 (Lollipop)? but still not satisfy my problem.

My application is almost similar to ES Explorer, where it will display all files to edit. When user finish editing the file, it will save the changes through this call OtherPartyImageSaver.save(File f, Metadata updatedMetadata)

I tried the following, but failed:

Uri treeUri = resultData.getData();
DocumentFile pickedDir = DocumentFile.fromTreeUri(this, treeUri);

OtherPartyImageSaver.save(new File("/storage/sdcard/Download/hello.jpg"), 
    updatedMetadata);

This class doesn't work with OutputStream.

Do I have to give up on OtherPartyImageSaver or is there any way to achieve this?

If I have to give up with the library, can Uri from other provider be granted for modification?

Uri mediaUri = Uri.withAppendedPath(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, 
    "45");

Because the Uri _ID is retrieved by querying database.

Community
  • 1
  • 1
sancho21
  • 3,511
  • 1
  • 39
  • 45
  • "My application is almost similar to ES Explorer, where it will display all files to edit" -- then query `MediaStore` to get at all known images and work with the `Uri` that you get back, or use the Storage Access Framework per the link in your question, rather than trying to work with the filesystem directly. Beyond that, nobody on the planet has any idea what `OtherPartyImageSaver` is. At the present time, this is the only page in Google's search engine that refers to this name. Hence, we cannot tell you whether to "give up" on it or not, because we do not know what it is or what it does. – CommonsWare May 16 '15 at 16:00
  • Basically the OtherPartImageSaver is a class from a thirdparty library that only works with java.io.File only. It modifies some information within the file. There is also another library that works the following way to modify files: `new OtherPartyImageWrapper(File file).update(Metadata newMetadata)` – sancho21 May 16 '15 at 22:19

1 Answers1

1

Do I have to give up on OtherPartyImageSaver

If it only works with File, and you want to support removable storage, then either you will have to give up on OtherPartyImageSaver, or you will have to modify it to support streams (if the class is open source).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491