Preload/replace SQLite db file

I am trying to preload a SQLite db file to my app. I would like to download it from a URL. I was following this example here but it does not seem to work after SDK 18 from what I’ve read.

I am trying to use FileSystem.

Expo APIs that create files generally operate within these directories. This includes Audio recordings, Camera photos, ImagePicker results, SQLite databases and takeSnapShotAsync() results. This allows their use with the FileSystem API.

Based on the comment here, I am just trying to read from the file location first before attempting to write which should be possible with the FileSystem API: Where does Expo store its SQLite databases? - #5 by nikki

I created a dummy db file like so, so as to make sure the SQL directory exists:
const dbTest = SQLite.openDatabase('dummy.db');

Later I am doing:
Expo.FileSystem.getInfoAsync('SQL/dummy.db');

but I get error:

[Unhandled promise rejection: Error: File ‘file:///var/containers/Bundle/Application/998ACE3A-844D-456D-8915-880BEE32DCAA/Exponent.app/SQL/dummy.db’ isn’t readable.]

How can I read/write from the SQL folder?

1 Like

The folder is named “SQLite” not “SQL” and is under FileSystem.documentDirectory

2 Likes

Doh, thanks so much.