Android database approach for future updates

后端 未结 4 1871
一向
一向 2021-01-16 19:09

What is the best way to work with the sqlite database in android?

The sqlite database file (copy it for the first time into the application environment)

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-16 19:34

    For large amounts of data you might want to consider this kind of solution: Create an empty database in code and provide an activity which responds to an intent with this action: android.intent.action.SEND. Respond by parsing the sent file and populate the database with the contents. Design a format which can be easily parsed (XML is not needed for everything ;-) so the code to parse the file and fill the database is small (my binary for this including an UI to show progress (which is the larger part of the activity) is less than 12 kB in size).

    The file may be distributed separately (extra apk, download, whatever). The benefit of this approach is that you do not need to store your initial database content within the apk and thus the data is only stored once on the device (after the file has been deleted). Otherwise you have the data in the database plus the source code or asset in the apk.

提交回复
热议问题