I'm using the Android emulator so I put users.db in 'android/app/src/main/assets/users.db'. I already ran npx react-native link
to make the link. I'm using a React Native version above 6.0 with auto-link.
I'm getting "Error: Could not open database":
import React, {Component} from 'react'
import {View, Text, Alert} from 'react-native'
import SQLite from 'react-native-sqlite-storage'
export default class App extends Component {
constructor(props) {
super(props)
SQLite.openDatabase({name:'users', createFromLocation:1}, this.connected, this.failed)
}
connected= () =>{
Alert.alert('Connected with success !')
}
failed= (e) =>{
Alert.alert('Something went wrong !', `${e}`)
}
render(){
return(
<View>
<Text>Testing SQLite</Text>
</View>
)
}
}
When changing the attribute
createFromLocation
to number 2 the system creates its own database which comes empty, so you need to create the tables. Unfortunately I didn't manage to use my old database.