mardi 4 août 2015

Android SQLite INSERT INTO TABLE VALUES

i am getting this error:

android.database.sqlite.SQLiteException: near ":12": syntax error (code 1): while compiling: INSERT INTO TIME VALUES(15:12);

my code is below:

SQLiteDatabase db = openOrCreateDatabase("timedb", Context.MODE_WORLD_WRITEABLE, null);
            s = (timePicker.getCurrentHour().toString() +" : " + timePicker.getCurrentMinute().toString());
            s = "'" + s + "'";


            db.execSQL("CREATE TABLE if not exists TIME"+" ("+ "times" +" VARCHAR(100)"+");");
            query = "INSERT INTO TIME"+ "VALUES"+"("+s+")";
            db.execSQL(query);
            startActivity(new Intent(Preferences.this, MainActivity.class));

I'm sure, that i am getting error from this piece of code. Can someone help me?

Aucun commentaire:

Enregistrer un commentaire