1

I have a rather large SQLite database (~20 mb) I need to access from my Android Xamarin-Forms app.

Everything online I've read says you can read the database by copying it to the filesystem first. For example, this question. However, won't that mean the large database is duplicated, wasting users' precious space (and nearly doubling the footprint of my app)?

There must be a way to read the SQLite database directly from the assets, or use some other method to bundle the database with my app that won't waste so much space. But how can I do this?

Community
  • 1
  • 1
BlueRaja - Danny Pflughoeft
  • 84,206
  • 33
  • 197
  • 283
  • if the database structure is simply enough, you could generate the entries at runtime, the first time the database is created. If it is not the case I agree with the answer you already got. Btw what are you storing in the db to reach 20 mb ? – Blackbelt Jun 22 '15 at 08:23
  • @Blackbelt: Dictionary (etc.) data for Japanese words/characters. The XML version of [JMDict](http://www.edrdg.org/jmdict/j_jmdict.html) alone is 45mb, which is why I'm parsing/storing/compressing it using SQLite. – BlueRaja - Danny Pflughoeft Jun 22 '15 at 08:24

1 Answers1

3

You don't want to use it from assets, even if you could, because assets is a compressed read only file, part of your installation. You can't write updates into it, which kills 90% of database use. And its inefficient for reading as its zipped up. So you really do need to copy it. If you're worried about disk space, consider downloading it from the web rather than keeping it in your apk.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • Is there some other way to include this database with my app that won't take up too much space? The database is already fairly well compressed. – BlueRaja - Danny Pflughoeft Jun 22 '15 at 08:17
  • Not really. Assets and raw files are the only way to include a file as part of an app, and moving it to raw won't save any space- the apk itself is a zip file. Its going to make it about as small as you're going to get. Like I said- if you're really concerned about the double disk space, download it at first boot. – Gabe Sechan Jun 22 '15 at 08:20