سؤال

I am building an application which currently has 11 columns and 120~ rows of text data in one of its few tables. It will likely be the only table which is pre-populated for the user, however, I am trying to figure out what the best method is for populating the data. I see a few different options.

  1. Run insert statements during oncreate of the database
  2. Create a table in the assets folder which already has the data and copy it over when the application is created.

What is the best practice for something like this? Over time, the database will be updated with a few more rows. I am looking at maybe a few rows a month, nothing too big.

Any help would be greatly appreciated.

هل كانت مفيدة؟

المحلول

What is the best practice for something like this?

Option #2, specifically using SQLiteAssetHelper. It will be faster than executing SQL transactions and is easier as your pre-loaded contents get more complicated.

Over time, the database will be updated with a few more rows. I am looking at maybe a few rows a month, nothing too big.

If the database is purely read-only (i.e., will not be modified by your app at runtime based on user input), you have the option of distributing your updates via updates to the app itself. Otherwise, you will need to download the information for those changes and apply them, perhaps in response to a GCM message or a very occasional polling check.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top