react-native-sqlite-storage
react-native-sqlite-storage copied to clipboard
Can not open database in android
I try to open database with database is located in internal storage on Android. But got error "Could not open database"
my code :
const db = await SQLite.openDatabase({name : "app_update", createFromLocation : "/storage/emulated/0/app_update.sqlite"});
error log:
openDatabase {"assetFilename": "/storage/emulated/0/app_update.sqlite", "createFromLocation": "/storage/emulated/0/app_update.sqlite", "dblocation": "nosync", "name": "app_update"} [[Error: Could not open database]]
my package.json:
{
"name": "awesomeproject",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "17.0.2",
"react-native": "0.67.4",
"react-native-sqlite-storage": "^6.0.1"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "7.14.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.66.2",
"react-test-renderer": "17.0.2"
},
"jest": {
"preset": "react-native"
}
}
Try this
const db = SQLite.openDatabase({name:'app_update',createFromLocation:'~ app_update.sqlite',location:'default'}, openCB, errorCB);
Hi @iphonic
Try this
const db = SQLite.openDatabase({name:'app_update',createFromLocation:'~ app_update.sqlite',location:'default'}, openCB, errorCB);
I have try it, but it only open database from local app, can not open database from external storage, example: from Download folder in Android
it
me too
Hi there, I facing the same issue, is there any way to fix it ? and the error in log said "Could not open database"
import RNFetchBlob from 'rn-fetch-blob';
creo que le falta importar el archivo desde el proyecto al dispositivo antes de abrir la DB.