Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/213.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带append参数的Android SAF openOutPutStream_Android_File_Storage Access Framework - Fatal编程技术网

带append参数的Android SAF openOutPutStream

带append参数的Android SAF openOutPutStream,android,file,storage-access-framework,Android,File,Storage Access Framework,使用经典的文件系统API,我们可以获得一个带有附加参数的输出流,以写入文件的末尾 以下是我用来访问文件的代码: 经典文件系统API: boolean append = true; File target = new File(...); OutputStream outStream = new FileOutputStream(target, append); SAF API: boolean append = true; File target = new File(...); Docume

使用经典的文件系统API,我们可以获得一个带有附加参数的输出流,以写入文件的末尾

以下是我用来访问文件的代码:

经典文件系统API:

boolean append = true;
File target = new File(...);
OutputStream outStream = new FileOutputStream(target, append);
SAF API:

boolean append = true;
File target = new File(...);
DocumentFile targetDocument = getDocumentFile(target, false, context);
OutputStream outStream = context.getContentResolver().openOutputStream(targetDocument.getUri());
但是我在SAF API中没有append参数

我们如何使用SAF API附加到文件中?

使用此选项。查看mode的文档,您可以将wa作为附加到任意文件的模式传递

然而,wa是一种复杂的模式,如中所述,它需要文件可查找,但只有从文件对象获取时,ParcelFileDescriptor才可查找,因此只有在Android O支持本地存储的提供商才能支持它

引用openFile和openAssetFile的原因是在DocumentsProvider的源代码中,因为它们都委托给openDocument,所以这两个文档都适用