带append参数的Android SAF openOutPutStream
使用经典的文件系统API,我们可以获得一个带有附加参数的输出流,以写入文件的末尾 以下是我用来访问文件的代码: 经典文件系统API:带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
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,所以这两个文档都适用