android - SQLite connection:application stops working -


i making diary application in android supposed data text fields.

when run app on emulator, gets installed give input in fields , tap save option in menu, emulator prompts diary app has stopped working.

i not able find database folder in app in emulator's file explorer means database not making.

here sqlite connection making , insertion in table code writing in save item.

    if(item.getitemid()==r.id.save){      edittext et=(edittext)findviewbyid(r.id.mood);         string mood=et.gettext().tostring();         et= (edittext)findviewbyid(r.id.weather);         string weather=et.gettext().tostring();         et= (edittext)findviewbyid(r.id.text);         string text=et.gettext().tostring();         date date= new date();         simpledateformat sdfdate = new simpledateformat("yyyy-mm-dd hh:mm:ss");         string strdate = sdfdate.format(date);          sqlitedatabase db= openorcreatedatabase("diarydatabase",mode_private,null);         db.execsql("create table if not exist diary ('mood varchar' , 'weather varchar' , 'text varchar' , 'time varchar' , 'id integer primary key');");         db.execsql("insert diary values(mood,weather,text,strdate,null);");         db.close();     } 

i think both e.q. ddl , dml statement incorrect. try replace yours following:

string createquery = "create table if not exist diary (" + "id integer primary key, " + "mood text, " + "weather text, " + "content text, " + "time text" + ")"; 

here:

insert diary values(mood,weather,text,strdate,null); 

your origin create statement create pk column last column , here in insert statement trying insert null pk not allowed , doesn't make sence since pk unique identifier of each row.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -