I've come across a couple of various ways that you could utilize SQLite because the database for the application. They're the following:

  • Database is produced and information is imported with an XML file.
  • Utilization of a SQLite GUI (SQLite Database Browser)
  • Straight Database creation using a Database assistant class.

Do you know the advantages of each one of these? I am leaning towards using SQLite Database browser to load a couple of tables I'll requirement for my application. I can also get user input.

Would you claim that I've one more table for his or her input and Union, or permit the user to input into table I've provided. The main one problem I anticipate is on upgrade from the application (through the Market), I don't want the consumer to get rid of data they have joined.

Thanks!

One option that we did:

  • Store each one of the schema and data population files as scripts in assets
  • Produced a wrapper class that runs individuals scripts from assets
  • Among the resource files is a common (by title) manifest, it's a listing from the scripts to operate by which order.
  • I've got a poperties table within the database which stores what is the last script that went.

Which means:

  • On creation (first run) - it runs all scripts in succession
  • When application is updates - it runs all scripts that haven't run yet. The update carries more scripts in assets.

The scripts update schema and modify/munge existing customer data - obviously without loss of data.

BTW, Used to do this on iOS using the intent of discussing individuals sqlite scripts between android, winphone along with other platforms. You simply need the wrapper class on each platform that runs the sequences.

Additionally, it means I'm able to run the scripts so as in the cmdline to produce a db as needed ...

EDIT:

For instance, during my sample application, Update1.sql is really a file added like a resource. It's two sql batches inside it. My wrapper opens the manifest file, get's their email list of scripts to operate, queries the database to determine the final script went, then produces a range of scripts to operate. If this runs Update1.sql which is incorporated in the list, my wrapper class executes all of the claims for the reason that file thats embedded like a resource. For instance, here's my Update1.sql

alter table messages add column user text;

create table log
(
    id integer primary key autoincrement, 
    information text    
);

Now, let us the new table produced needs some data inside it. (during my situation a log table does not). That scripts could contain a number of place into claims immediately after the create table.

Performing multiple batches inside a script requires using the tail argument in prepare. I've C/objective-c code if you'd like to determine it however i haven't written the android wrapper yet ...