I have to bake in a 15MB csv into my new app and t...
# squarelibraries
c
I have to bake in a 15MB csv into my new app and then immediately on launch start inputting it into my sqldelight db. Can I just skip that middle step and ship a db/table with my android app?
👌 5
You're mostly on your own for this because it really has nothing to do with SQL Delight.
To the library, a pre-populated DB that's copied into the correct location on first launch is indistinguishable from an existing db that was created from scratch by some previous launch.
They're both just a file that's in a particular place.
there's probably even more...
c
Thanks! "pre-populated" was the magic word I was missing during search.
But cool. Seems like the tl;dr is that 1. ship a raw db asset with my app 2. and then just move the db into the right folder. 3. done?
j
yep, that's it. you just have to do it early.
❤️ 1
e
if you had an sqlite built with https://sqlite.org/zipfile.html you could use a read-only database directly from a raw asset inside your app, since apks and ipas are basically zipfiles (this is theoretical unless you bundle your own sqlite build, since the platform sqlite doesn't include the zipfile module)
👀 1
c
Ooh. Interesting! In that case though I wouldn't be able to make changes to it though (IIUC)
m
@ephemient that’s interesting. I’ve long-asked for such a possibility https://issuetracker.google.com/issues/134928363 Is it worth requesting google to add the zipfile module to platform sqlite?
c
@Mark is there some issue with copying it to storage first? or just the simple fact that it's something that has to be done/could take time?
m
I think the biggest thing is the potential for failed startup because insufficient storage space (or perhaps some I/O error). Extra code and time on first launch (like you said) are also factors. Another thing to think about is whether to create the indexes upfront, or on first launch (i.e. after copying the db to local storage), although this is probably only worth doing if you have very large indexes.
c
oh. indexes are something i haven't thought about. Thanks for the tips!