In React Native Expo project, I am using Expo DocumentPicker to select a JSON file and load it into the application.
On modern version of Android there is no problem with this, in file explorer I select the desired JSON file and upload it. But on older versions of Android( 7, 8) I can’t select the JSON file, I can see it in file explorer but it is not available for selection.
If I remove type: ‘application/json’, I can select json file, but other file types are also available for selection.
const uploadJsonFile = async () => {
try {
const file = await DocumentPicker.getDocumentAsync({
copyToCacheDirectory: true,
type: 'application/json',
});
setUploadedBackup(file.assets);
} catch (err) {
console.log(err);
}
};
How can I solve this problem? I can find out the Android version and if the version is below a certain value not specify the file type to select. But from which Android version there is no problem with selecting ‘application/json’?
You need to sign in to view this answers
Leave feedback about this