android - Sqlite create db with multi tables from raw file -
i want create db 2 tables in sqlite. 1 table work 2 not. have in raw folder 1 create_schema.sql file with:
create table user_usa ( _id integer primary key not null unique, user varchar not null unique, pass varchar not null unique, cod varchar ); create index unique_entry_date on user_usa (_id);
and have this:
if (mdb == null || !mdb.isopen()) { final file dbfile = mcontext.getdatabasepath(mydbclass.db_name); final boolean wasexisting = dbfile.exists(); if (!wasexisting) { // read sql create db final string createdbstatement; try { createdbstatement = resourceutils.getrawasstring(mcontext, r.raw.create_schema); // if it's not present create databaseutils.createdbfromsqlstatements(mcontext, mydbclass.db_name, db_version, createdbstatement); } catch (ioexception e) { e.printstacktrace(); log.e(tag_log, "error creating db", e); return; } } mdb = mcontext.openorcreatedatabase(mydbclass.db_name, context.mode_private, null); }
now if try modify create_schema.sql file below not work:
create table user_usa ( _id integer primary key not null unique, user varchar not null unique, pass varchar not null unique, cod varchar ); create table google_key ( _id integer primary key not null unique, regid varchar not null unique, ); create index unique_entry_date on user_usa (_id); create index unique_entry_date on google_key (_id);
where i'm wrong?
error:
android.database.sqlite.sqliteexception: no such table: google_key (code 1): , while compiling: select * google_key
this improper ending create table statement:
create table google_key ( _id integer primary key not null unique, regid varchar not null unique, );
there hanging comma there, table won't constructed. @ ending of first create table statement, , fix 1 one.
Comments
Post a Comment