I defined column name. but I confront this error. I checked every thing. I cant find the reason of this error .
try { myDB = this.openOrCreateDatabase("DatabaseName", MODE_PRIVATE, null);
/* Create a Table in the Database. */
myDB.execSQL("CREATE TABLE IF NOT EXISTS "
+ TableName
+ " (" +
"name TEXT, " +
"number TEXT" +
");"
);
/* Insert data to a Table*/
myDB.execSQL("INSERT INTO "
+ TableName
+ "(name,number)"
+ " VALUES (name,number)");
// retrieve data from database
Cursor c = myDB.rawQuery("SELECT * FROM " + TableName , null);
// Check if our result was valid.
c.moveToFirst();
while(c.moveToNext())
{
Log.i("error",c.getString(0));
Log.i("error",c.getString(1) );
contactname.add(c.getString(c.getColumnIndex("name")));
contactnumber.add(c.getString(c.getColumnIndex("number")));
}
Aucun commentaire:
Enregistrer un commentaire