java - can't insert into sqlite database, error: Table doen't exist -



java - can't insert into sqlite database, error: Table doen't exist -

i have been trying solve seems simple problem lastly 3 days, trying insert record sqlite database activity, have searched issue without look. below find activity code , dbhelper code. dbhelper code:

public long insertresult(string quest_id,string test1,string test2) { sqlitedatabase db = this.getwritabledatabase(); contentvalues initialvalues = new contentvalues(); initialvalues.put("question", quest_id); initialvalues.put("rights", test1); initialvalues.put("wrongs", test2); log.d("result:", "rights " + initialvalues.get("rights")); homecoming db.insertorthrow("results", null, initialvalues); } mainactivity long ins = mydbhelper.insertresult("test","test2","test3");

results table doesn't exist in database.

it looks dbhelper extending sqliteopenhelper. should override oncreate method in dbhelper. example, add together this:

@override public void oncreate(sqlitedatabase db) { db.execsql("create table results (_id integer primary key autoincrement, question text not null, rights text not null, wrongs text not null);"); }

if ever alter database schema you'll need override onupgrade method.

java android sqlite android-studio

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -