Catch possible exception in getDownloadsUri

This commit is contained in:
emanuele-f 2023-02-04 11:28:12 +01:00
parent 4bd4223333
commit 3618f1e211
2 changed files with 11 additions and 3 deletions

View File

@ -803,9 +803,16 @@ public class Utils {
}
} catch (Exception ignored) {}
Uri newUri = context.getContentResolver().insert(externalUri, values);
Log.d(TAG, "getDownloadsUri: new file " + newUri);
return newUri;
try {
Uri newUri = context.getContentResolver().insert(externalUri, values);
Log.d(TAG, "getDownloadsUri: new file " + newUri);
return newUri;
} catch (Exception e) {
// On some devices, it may trigger "IllegalArgumentException: Volume external_primary not found"
Log.e(TAG, "getDownloadsUri failed:" + e.getMessage());
Utils.showToastLong(context, R.string.write_ext_storage_failed);
return(null);
}
}
public static boolean isRootAvailable() {

View File

@ -453,4 +453,5 @@
<string name="pcapng_format_summary">Dump packets in the pcapng dump format, which allows embedding TLS decryption secrets</string>
<string name="sort_by">Sort by</string>
<string name="total_bytes">Total bytes</string>
<string name="write_ext_storage_failed">Write to external storage failed. Check the app log for details</string>
</resources>