Reputation: 2633
I want to use a single query to insert into a table and if that table is not yet created create it and perform the insertion
Any ideas, answers suggestions or sample queries are welcome
Advanced thanks for all
Upvotes: 1
Views: 100
Reputation: 5278
Use SQLiteDatabase.execSQL()
command, and execute two queries seperated by ';', like:
db.execSQL("create table if not exists('columns and details here');insert into 'whatever you want to insert');"
Upvotes: 1
Reputation: 10856
first you have to ckeck that table is already created or not so use this query
CREATE TABLE IF NOT EXISTS "abcxyz" ( ' +
'"id" INTEGER PRIMARY KEY AUTOINCREMENT,' +
'"vorname" TEXT,' +
'"name" TEXT,' +
'"geburtsdatum" TEXT,' +
'"suchid" TEXT )'
and than write your insert query.
Upvotes: 0