Hello,
I have a SQL Lite DB which i need to use within my app.
My DB is located at myApp/assets/db/test.db
And i try to download my db into documentDirectory/SQLite.
But i have this error 'Unable to resolve module ‘./assets/db/test.db’
I used this example : https://github.com/expo/test-suite/blob/master/tests/SQLite.js.
And i tried this solution too : SQLite existing database - #5 by thoughtco
Here is my code :
import AppNavigator from "./navigation/Navigation";
import React from "react";
import { StyleSheet, View } from "react-native";
import { SQLite, FileSystem as FS, Asset } from "expo";
export default class App extends React.Component {
componentDidMount() {
FS.downloadAsync(
Asset.fromModule(require("./assets/db/test.db")).uri,
`${FS.documentDirectory}SQLite/test.db`
);
}
render() {
return (
<View style={styles.container}>
<AppNavigator />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff"
}
});
And in my app.json :
"packagerOpts": {
"assetExts": ["db"]
}
Can somebody explain to me what I’m doing wrong?
Thanks