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)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android App Developer Training:  http://commonsware.com/training 

--


Sponsored Links


Creating databases

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


 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 







--



Other Threads

1. How could I get raw touch screen data

RT
Actually I wanna detect the shape of touch point, i.e. the shape of
finger touch on the screen

Seems that the only information I can get in touch event is the size
of the touch point(by event.getSize())

By the implementation of the screen,
the shape(and pressure of each point in the shape) of the touching
finger should be the first raw data that the hardware can detect

So, how could I get these raw data?

thx very much for any help~~~~~~

-- 

2. Samsung Galaxy Tab: AVD add on package

Guys I found this today http://innovator.samsungmobile.com/galaxyTab.do
and was able to install the package into my avd manager and I now have
the Galaxy Tab emulator running.

-- 

3. When I can't view the file under SDcard

4. GLSurfaceView.onSurfaceCreated not being called when activity resumes

5. Is it possible to make the LED / trackball pulse while the screen is on ?

6. Life after G1

7. could you change maximum log length?