Creating databases

by Neilz » Tue, 15 Dec 2009 07:42:36 GMT

Sponsored Links
 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.


Creating databases

by Mark Murphy » Tue, 15 Dec 2009 07:46:49 GMT


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)  | 

Android App Developer Training: 


Sponsored Links

Creating databases

by jeffro » Wed, 16 Dec 2009 00:49:14 GMT

 Here's an example:

        public void onCreate(SQLiteDatabase db) {
                Log.d(getClass().getName(), "Creating Database.");

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);";

Trackmaster - Motorsports Lap Timer 
Dynomaster - Performance Dyno 


Other Threads

1. Call Recording on Android 2.3

Is Voice call recording now possible on android 2.3 without going on
to the speakerphone mode? Thanks


2. Query in calling SOAP based web service in Android

Hi All ,

I am new to Android .

I am developing one application .

In which , i need to use SOAP based web service.

but i am not able to do this task .

I need to pass class object as a argumens while calling web service
method .
And I am getting error regarding "Serialize" .

Now , I change the way of calling web service and

I want to pass xml data as a argumens ..

Is there any solution for this problem ???

Is there any relavant link ??

thanks & Regards

Nandlal Virani


3. How can I re-init the screen

4. times_contacted not being updated on some devices

5. Media Player - crop video for fullscreen mode

6. Android OS Gingerbread modification for enabling of the two other modes for NFC

7. [Edited]: WTB - Nexus one atau hd2 atau defy bnib, atau Motorola Milestone xt720