I want to insert into the database .. form value. Two of them are integers, and one is a string .. but I cannot view the value that I entered in my sqlite viewer for the database. I am using the following code:
SQLiteDatabase myDB= null;
String TableName = "basicdetai";
try{
myDB = this.openOrCreateDatabase("Medical", MODE_PRIVATE, null);
myDB.execSQL("CREATE TABLE IF NOT EXISTS "
+ TableName
+ " (order_id INT(4), doc_id INT(4),doc_name VARCHAR );");
myDB.execSQL("INSERT INTO "
+ TableName
+ "(order_id,doc_id,doc_name)"
+ " VALUES ("+ ordid + ","+ doci + ","+ docnam +");");
}
catch(Exception e) {
Log.e("Error", "Error", e);
}
finally {
if (myDB != null)
myDB.close();
}
but when I use line 11 in the above code, I can see the record (5011,4011,'gupta')through sqlite browser. I perform the following operation to convert a string value that I get from a form to an integer
try {
ordid = Integer.parseInt(orderid.getText().toString());
doci = Integer.parseInt(docid.getText().toString());
} catch(NumberFormatException nfe) {
System.out.println("Could not parse " + nfe);
}
Help Plz.
source
share