I wrote the following code but some reason insert function does not work. I tryed remove the database and the tables but nothung work!!
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + steps_table + " ( "+id_col+" INTEGER PRIMARY KEY AUTOINCREMENT, "
+steps_number_col+" INTEGER, " + date_col+" TEXT) ");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + steps_table);
onCreate(db);
}
public boolean addStep(Step step)
{
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("CREATE TABLE " + steps_table + " ( "+id_col+" INTEGER PRIMARY KEY AUTOINCREMENT, "
+steps_number_col+" INTEGER, " + date_col+" TEXT) ");
ContentValues contentValues = new ContentValues();
contentValues.put(steps_number_col, step.stepNumber);
contentValues.put(date_col, "dfg");//new SimpleDateFormat().format(step.date));
if (db.insert(steps_table, null, contentValues) != -1)
return true;
return false;
}
Aucun commentaire:
Enregistrer un commentaire