What does “putting in an SQLite folder in the root of my app” mean? If you use the FileSystem API’s .downloadAsync method to download a file to documentDirectory/SQLite, you can open it. You can find an example in https://github.com/expo/test-suite/blob/master/tests/SQLite.js in the “should work with a downloaded db file” test.
“putting in an SQLite folder in the root of my app” meant literally that, putting the folder in an SQLite folder - having read through other comments that seemed to be what resolved it for others.
I looked at the .downloadAsync code but its unfortunately throwing an error for me:
“Unable to resolve module ./assets/db/nrsv.db from /Users/ryan/Apps/Lectionary/App.js: could not resolve /Users/ryan/Apps/Lectionary/assets/db/nrsv.db as a file or folder.”
The file exists in this location, and is a valid SQLite file - are you able to offer any guidance on what the error might be?
The problem could be that the .db extension is ignored by the React Native packager (aka Metro). In your project’s app.json file, insert as appropriate:
That seemed to help… in the end my code looked like:
// load in db
Expo.FileSystem.downloadAsync(
Expo.Asset.fromModule(require('./assets/db/NRSV.db')).uri,
`${Expo.FileSystem.documentDirectory}SQLite/nrsv.db`
);
A lot of the code samples (including the 2nd comment here) used Expo.FS rather than Expo.FileSystem - I found once I switched over to the latter it worked without issue…
It might be worth adding something on this to the SQLite documentation as it seems like a regular use case.