mardi 24 mars 2015

rawQuery() in Android SQLite not compiling parameters

While trying to implement SQLite storage ran into strange behavior. The "?"-symbols are not substituted.


My code:



public class DBHandler extends SQLiteOpenHelper {

public void writeTask(JSONObject object) throws JSONException {
SQLiteDatabase db = this.getWritableDatabase();
String id = object.get(OBJECT_ID).toString();
String content = object.toString();
String md5 = "md5"; //testing

Cursor c = db.rawQuery("INSERT OR REPLACE INTO ? ( ? , ? , ? ) VALUES ( ? , ? , ?);", new String[] {TABLE_OBJECTS, OBJECT_ID, OBJECT_CONTENT, OBJECT_MD5, id, content, md5 });
}
}


Then it throws a strange error:



android.database.sqlite.SQLiteException: near "?": syntax error (code 1): , while compiling: INSERT OR REPLACE INTO ? ( ? , ? , ? ) VALUES ( ? , ? , ?);


I saw different examples here, cloned the syntax, but still get this error.


Aucun commentaire:

Enregistrer un commentaire