in my android app I am extending SQLiteOpenHelper to create a SQLite database.
Here is my onCreate method:
@Override
public void onCreate(SQLiteDatabase database) {
String sql = "CREATE TABLE ? ( " + SuggestionColumns._ID + " INTEGER PRIMARY KEY)";
String[] params = new String[]{SuggestionColumns.TABLE_NAME};
database.execSQL(sql, params);
But LogCat prompts me the following error:
10-10 00:55:03.255: E/SQLiteLog(22311): (1) near "?": syntax error
10-10 00:59:20.605: W/SuggestionsAdapter(22311): Search suggestions query threw an exception.
10-10 00:59:20.605: W/SuggestionsAdapter(22311): android.database.sqlite.SQLiteException: near "?": syntax error (code 1): , while compiling: CREATE TABLE ? ( _id INTEGER PRIMARY KEY);
But if I substitute the placeholder with a string and call execSql(sql); it works.
So the question is: is it forbidden to use placeholders in CREATE TABLE statements?