This error happen after i copy a file of my personal path, how documents, downloads, DCIM… to root path of my app, the folder of database of my app, i am using sqlite3.
So i search for solution for long time and nothing that i tried did not work.
but i just change the androidmanifest.xml, and dont work, im using react native then i should change my code?
this is my androidmanifest.xml:
<manifest>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28"
/>
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="28"
/>
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
android:maxSdkVersion="28"/>
...
<application
android:requestLegacyExternalStorage="true"
android:preserveLegacyExternalStorage="true"
... >
...
<activity>
...
</activity>
</application>
</manifest>
and this my code react native to copy to database app path:
const importDB = useCallback(async () => {
try {
const response = await DocumentPicker.pick({
presentationStyle: 'fullScreen',
copyToCacheDirectory: true,
});
setFileResponse(response);
response.map((file, index) => (
ulr_import = file?.uri
));
FileSystem.copyFile(ulr_import, `/data/user/0/com.app/databases/database.db` )
.then((success) => {
console.log('file moved!'+success);
Alert.alert('Confirmation', 'Sucess', [
{text: 'OK', onPress: () => console.log('OK Pressed')},
]);
})
.catch((err) => {
console.log("Error: " + err.message); // <--- but copyFile returns "doesn't exists" error for temp.jpg
Alert.alert('Erro', err.message, [
{text: 'OK', onPress: () => console.log('OK Pressed')},
]);
});
} catch (err) {
console.warn(err);
}
}, []);