Where does Expo store its SQLite databases?


#1

I’m developing a small app, and would like to view and edit the contents of the SQLite database generated by it, to speed up development. I am creating it with the following command:

db = Expo.SQLite.openDatabase('dbname');

Where is it?


#2

Relatedly; how do I drop the database easily to start again?


#3

What do you mean by “where is it”? The resulting “db” variable can be used to access the database now.


#4

The database file. Like I said, I want to view and edit the contents of it, such as with http://sqlitebrowser.org/


#5

https://github.com/expo/expo/blob/d3e0190f900de5a688561d458b38ad592675b760/ios/Exponent/Versioned/Modules/Api/EXSQLite.m#L38-L40 is how the path is generated on iOS.

https://github.com/expo/expo/blob/d3e0190f900de5a688561d458b38ad592675b760/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/SQLiteModule.java#L173-L175 is how it’s generated on Android.

Expo.FileSystem.getInfoAsync('SQLite/<dbfilename>') will return a an object in which the uri property will have the file:// URI of the database file in your device / emulator / simulator.

Let me know if you need more clarification on this. :slight_smile:


Preload/replace SQLite db file
#6

https://github.com/expo/test-suite/blob/29e6e7692e365bc5430f693e1c13fd4ce37348d3/Tests/SQLite.js#L58-L65 shows how to get the file:// URI to the database file. If you are on iOS simulator on macOS, the path with the file:// prefix cut off should give you an absolute path to the file on macOS.

Expo is getting a proper FileSystem API soon that should address this in a proper way.


#7

I’m still trying to find the database. I’m using Expo on a Mac Air, and the project is simply on my desktop. Unless I’m missing something, the database should reside in my project folder. In any event, I’m still unclear how to find the folder with the database file…has anybody found a way I could find this the terminal?


#8

Amweiss, the database will reside on your device, not your desktop.

Nikki, thanks; I’ll try that today.


#9

Thanks asday…makes sense…above it says “If you are on iOS simulator on macOS” you can find the path, etc, and I’m using the IOS simulator on a mac, but not sure where you look for that path…anybody know this? Thanks.


#10

In case other people need this, if you are on a mac using an IOS simulator you can find the database by opening terminal and adding these two lines:

cd Library/Developer/CoreSimulator/Devices

find $PWD -name “[your database name]” -print


#11

On Android, it’s under:
/data/data/host.exp.exponent/files/ExperienceData/YOURAPPNAME/SQLite/YOURDB