android - getting SQLException during runtime and the program is running properly, also no messages in the logcat -


i new sqlite. trying make simple application uses sqlite database. have completed of part, getting runtime exceptions.

here java file dbhelper-

temperature.java :-

package com.example.sqliteexample;  import android.content.contentvalues; import android.content.context; import android.database.cursor; import android.database.sqlexception; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sqliteopenhelper;  public class hotornot {  public static final string key_rowid = "_id"; public static final string key_name = "item_name"; public static final string key_temperature = "item_temperature";  private static final string database_name = "hotornotdb"; private static final string database_table = "itemtable"; private static final int database_version = 1;  private dbhelper ourhelper; private final context ourcontext; private sqlitedatabase ourdatabase;  private static class dbhelper extends sqliteopenhelper {      public dbhelper(context context) {         super(context, database_name, null, database_version);         // todo auto-generated constructor stub     }      @override     public void oncreate(sqlitedatabase db) {         // todo auto-generated method stub         db.execsql("create table "+database_table+" ("+                 key_rowid +" integer primary key auto increment, "+                 key_name+" text not null, "+                 key_temperature+" text notnull);"          );     }      @override     public void onupgrade(sqlitedatabase db, int oldversion, int newversion) {         // todo auto-generated method stub         db.execsql("drop table if exists "+database_table);         oncreate(db);     }  } public hotornot (context c){     ourcontext = c; } public hotornot open()throws sqlexception{     ourhelper=new dbhelper(ourcontext);     ourdatabase=ourhelper.getwritabledatabase();     return this; } public void close(){     ourhelper.close(); } public long createentry(string name, string hotness) {     // todo auto-generated method stub     contentvalues cv = new contentvalues();     cv.put(key_name, name);     cv.put(key_temperature, hotness);     return ourdatabase.insert(database_table, null, cv); } public string getdata() {     // todo auto-generated method stub     string[] columns = new string[]                                  {              key_rowid, key_name,key_temperature                                 };     cursor c = ourdatabase.query(database_table, columns, null,null,null,null,null);     string result = "";      int irow = c.getcolumnindex(key_rowid);     int iname = c.getcolumnindex(key_name);     int ihotness = c.getcolumnindex(key_temperature);     for(c.movetofirst(); !c.isafterlast();c.movetonext()){         result = result + c.getstring(irow)+ " "+         c.getstring(iname)+" "+c.getstring(ihotness)+"\n";      }     return result; } } 

i getting sqlexception, while running code. code syntactically good, can't understand, gone wrong.

this happened previously. now, in addition that, application not @ starting. no message there in logcat , status -

'activitymanager: starting: intent { act=android.intent.action.main cat=[android.intent.category.launcher] cmp=com.example.sqliteexample/.sqliteexample }'  

is missing in console. can 1 please give me solution this?

thanks in advance.

follow these steps

  • you need set android:debuggable="true" in application in androidmanifest.xml. if haven't set setting, debugging not enabled.
  • either start app right clicking on project , select
    debug as->android application or running , later in ddms perspective select running app in devices pane , click on green bug.

then please post log cat here.

source steps: how debug android application line line using eclipse?


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -