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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

