java.io.File和新的Lollipop SDCard Access API不能一起工作?

时间:2015-05-16 15:28:21

标签: android android-5.0-lollipop

我已经跟着这个How to use the new SD card access API presented for Android 5.0 (Lollipop)?,但仍然不满足我的问题。

我的应用程序与ES Explorer几乎相似,它将显示要编辑的所有文件。当用户完成编辑文件后,它将通过此​​调用OtherPartyImageSaver.save(File f, Metadata updatedMetadata)

保存更改

我尝试了以下操作,但失败了:

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

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

此课程不适用于OutputStream

我是否必须放弃OtherPartyImageSaver或者有没有办法实现这一目标?

如果我不得不放弃图书馆,可以批准其他提供商的Uri进行修改吗?

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

因为通过查询数据库来检索Uri _ID。

1 个答案:

答案 0 :(得分:1)

  

我是否必须放弃OtherPartyImageSaver

如果它仅适用于File,并且您想支持removable storage,那么您必须放弃OtherPartyImageSaver,否则您必须将其修改为{{ 3}}(如果该类是开源的)。