Here's an example:

        @Override
        public void onCreate(SQLiteDatabase db) {
                Log.d(getClass().getName(), "Creating Database.");
                db.execSQL(VEHICLE_CREATE);
                db.execSQL(RUN_CREATE);
                db.execSQL(DATA_CREATE);
                db.execSQL(SETUP_CREATE);
                db.execSQL(ET_CREATE);
        }

and the I have final strings like the following that contain the SQL
to create the table:

    private static final String VEHICLE_CREATE =
        "create table vehicle (_id integer primary key autoincrement,
vehicle text not null,notes text, selected boolean not null default
false,vehicle_uri text,weight real default 0.0,drivetrain_loss integer
default 17);";


Jeff
_______________________________
Trackaroo.com
Trackmaster - Motorsports Lap Timer http://trackmaster.trackaroo.com
Dynomaster - Performance Dyno http://dynomaster.trackaroo.com


On Dec 14, 3:46 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> Neilz wrote:
> > I've made a few apps now, which use an SQLite database, no problems.
> > In my latest app, I want two tables, and I just realised that every
> > example I can find only creates one table.
>
> > So, is this a limitation? Must I use only one table? Assuming I can
> > use two, how do I go about changing my create script? Here's a normal
> > one, as per the examples:
>
> > private static final String DATABASE_CREATE =
> >            "create table myTable (_id integer primary key autoincrement,
> > "
> >                    + "description text not null); " ;
>
> > If there's an example elsewhere, I'd be grateful for a link... thanks.
>
> In onCreate() of your SQLiteOpenHelper, you can call execSQL() as many
> times as you like, to execute as many SQL statements as you like. You
> can have as many tables, indices, triggers, and whatnot as SQLite
> allows, certainly greater than one of each.
>
> So, call execSQL() once to create one table and once to create another
> table. Or, courtesy of that semicolon, you may be able to put both
> CREATE TABLE statements in a single string -- I haven't tried that.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android App Developer Training:http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to