sancho21
sancho21

Reputation: 3643

java.io.File and new Lollipop SDCard Access API can't work together?

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.

Upvotes: 0

Views: 324

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006944

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).

Upvotes: 1

Related Questions