Skip to content

Commit 7996a43

Browse files
authored
Fix file picker compatibility with older Android versions for json import
See (historic) SO issue: https://stackoverflow.com/a/58104204 and introduction of the json mime type in 2018: https://android.googlesource.com/platform/libcore/+/d5e73ac1a2c92dd929e1462b63d6e36509813486
1 parent 99a7fae commit 7996a43

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/services/backup/backup_service.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ class ManualBackupService {
3636

3737
/// Imports all the notes from a JSON file picked by the user and returns whether the import was successful.
3838
Future<bool> import(BuildContext context) async {
39-
final importedFile = await selectAndReadFile(MimeType.json.value);
39+
// Compatibility: the json mime type was only introduced in Android 10; just specify binary for older versions
40+
final mimeType = InfoUtils().androidVersion < 29 ? "application/octet-stream" : MimeType.json.value;
41+
final importedFile = await selectAndReadFile(mimeType);
4042

4143
if (importedFile == null) {
4244
return false;

0 commit comments

Comments
 (0)