lundi 13 avril 2015

mysqlite table already in database must create via code

I created a table (Results) on SqliteBrowser, 1st the code complaints that the table does not exist. It works if insert the following code:



db.execSQL("create table Results (_id integer primary key autoincrement, Question text not null, Rights text not null, Wrongs text not null);");


but when I check the data with the following code the database, data is not there: public void checkTable(String table) { String sqlQuery = "SELECT * FROM " + table + "" ; Cursor d = myDataBase.rawQuery(sqlQuery, null); while (d.moveToNext()) { Log.d("CheckTable Content:", "" + table + ":Fields:" + d.getString(1) + " " + d.getString(2) + " " + d.getString(3));



}
}


Why do can't code recognized the table already created via sqlitebrowser, why do I have create the table again? and why I can't see my data from the table if the insertorthrow worked fine?



public void checkTable(String table) {
String sqlQuery = "SELECT * FROM " + table + "" ;
Cursor d = myDataBase.rawQuery(sqlQuery, null);
while (d.moveToNext()) {
Log.d("CheckTable Content:", "" + table + ":Fields:" + d.getString(1) + " " + d.getString(2) + " " + d.getString(3));

}
}

Aucun commentaire:

Enregistrer un commentaire