mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 02:54:11 +08:00
fix(android): crash on writeText on Android > 29 (#10466)
Co-authored-by: farfromrefuge <>
This commit is contained in:
@ -375,13 +375,13 @@ public class FileHelper {
|
|||||||
|
|
||||||
private OutputStream getOutputStream(Context context, Uri uri, boolean append) throws Exception {
|
private OutputStream getOutputStream(Context context, Uri uri, boolean append) throws Exception {
|
||||||
if (Build.VERSION.SDK_INT >= 19) {
|
if (Build.VERSION.SDK_INT >= 19) {
|
||||||
|
if (DocumentsContract.isDocumentUri(context, uri)) {
|
||||||
|
return context.getContentResolver().openOutputStream(DocumentFile.fromSingleUri(context, uri).getUri(), append ? "wa" : "w");
|
||||||
|
}
|
||||||
if (isExternalStorageDocument(uri)) {
|
if (isExternalStorageDocument(uri)) {
|
||||||
File file = getFile(context, uri);
|
File file = getFile(context, uri);
|
||||||
return new FileOutputStream(file, append);
|
return new FileOutputStream(file, append);
|
||||||
}
|
}
|
||||||
if (DocumentsContract.isDocumentUri(context, uri)) {
|
|
||||||
return context.getContentResolver().openOutputStream(DocumentFile.fromSingleUri(context, uri).getUri(), append ? "wa" : "w");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return context.getContentResolver().openOutputStream(uri, append ? "wa" : "w");
|
return context.getContentResolver().openOutputStream(uri, append ? "wa" : "w");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user