Android 棒棒糖SD卡文档编写

Android 棒棒糖SD卡文档编写,android,android-5.0-lollipop,document,android-sdcard,Android,Android 5.0 Lollipop,Document,Android Sdcard,我有一个第三方库,它接受文件对象并对其进行修改。 现在在获得SD卡使用许可后 Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); 选择SD卡根目录 然后用户浏览他想要修改的文件。现在这个 需要传递给第三方库类的文件路径/文件对象 DocumentFile documentFile = DocumentFile.fromFile(file); String documentURI = documentFile.getU

我有一个第三方库,它接受文件对象并对其进行修改。 现在在获得SD卡使用许可后

 Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
选择SD卡根目录

然后用户浏览他想要修改的文件。现在这个 需要传递给第三方库类的文件路径/文件对象

 DocumentFile documentFile = DocumentFile.fromFile(file);
 String documentURI = documentFile.getUri().toString();
 MP3File mp3File = null;

 documentFile = DocumentFile.fromFile(file);
 mp3File = new MP3File(file.getAbsolutePath());
这里,MP3File类接受文件路径。但是这个类没有任何文档构造函数

我是否可以将文档转换为可写文件,并用原始文件替换?还是有更简单的解决方案

现在在获得SD卡使用许可后。。。选择SD卡根目录

用户无需选择任何特定文档。文档可能位于可移动存储、外部存储、Google Drive、Dropbox、文件服务器或用户可以访问的任何其他位置

现在,我需要将这个文件的路径/文件对象传递给第三方库类

 DocumentFile documentFile = DocumentFile.fromFile(file);
 String documentURI = documentFile.getUri().toString();
 MP3File mp3File = null;

 documentFile = DocumentFile.fromFile(file);
 mp3File = new MP3File(file.getAbsolutePath());
该文档没有“路径/文件对象”

这里,MP3File类接受文件路径

要么:

  • 找到一个更好的库,一个接受
    InputStream
    和/或
    OutputStream
    的库,这样您就可以使用它所在的文档,或者

  • 使用Java I/O将文档内容复制到您控制的本地文件,然后将该文件传递到库

现在在获得SD卡使用许可后。。。选择SD卡根目录

用户无需选择任何特定文档。文档可能位于可移动存储、外部存储、Google Drive、Dropbox、文件服务器或用户可以访问的任何其他位置

现在,我需要将这个文件的路径/文件对象传递给第三方库类

 DocumentFile documentFile = DocumentFile.fromFile(file);
 String documentURI = documentFile.getUri().toString();
 MP3File mp3File = null;

 documentFile = DocumentFile.fromFile(file);
 mp3File = new MP3File(file.getAbsolutePath());
该文档没有“路径/文件对象”

这里,MP3File类接受文件路径

要么:

  • 找到一个更好的库,一个接受
    InputStream
    和/或
    OutputStream
    的库,这样您就可以使用它所在的文档,或者

  • 使用Java I/O将文档内容复制到您控制的本地文件,然后将该文件传递到库