I'm trying to implement my first application in react-native and I need to open database from a static file saved in my project folder.
I read that i need to allow loading custom extensions files from assets so i added following fragment into my app.json
file:
"packagerOpts": {
"assetExts": ["sqlite", "db"]
},
Next I'm trying to import this static file with .sqlite or .db extension inside my App.js component in componentDidMount()
method:
componentDidMount = async () => {
await Expo.FileSystem.downloadAsync(
Expo.Asset.fromModule(require("./assets/db/local.db")).uri,
`${Expo.FileSystem.documentDirectory}SQLite/local.db`
);
SQLite.openDatabase("local.db");
};
but expo builder keep saying Unable to resolve "./assets/db/local.db" from "App.js"
. Any suggestion please?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…