I already put the database file in the path \android\app\src\main\assets\www but the openDatabase() always return this error "Error opening database: [TypeError: Cannot convert null value to object]"
Inside the class object
class SQLiteWrapper {
private database: SQLite.SQLiteDatabase | null = null;
...
async openDB() {
if (await RNFS.exists(this.dbFilePath)) {
SQLite.openDatabase({
name: this.dbFilePath,
location: 'default',
}).then(db => {
console.info(`Database initialized ... ${db?.dbName}`);
this.database = db;
console.info(`Database initialized ... ${this.database?.dbName}`);
}
).catch(error => {
console.error('Error opening database:', error);
}
);
} else {
console.error('Error find database:');
}
}
Usage :
useEffect(() => {
...
SQLiteWrapper.openDB();
...
}, []);
I am using packages in react-native with typescript "react-native-sqlite-storage": "^6.0.1" "@types/react-native-sqlite-storage": "^6.0.0"
Already make sure the file can be copy to the location in this.dbFilePath
No idea is there the openDatabase looking for different path ? or typescript problem after opened the database ?
Any suggestions that I missed ?