[英]Android SQLite unrecognized token
Hi I am having trouble with an SQL database, it is giving me an error within my onCreate() method, I am relatively new to both database work and android programming so i'm really quite confused. 嗨,我在使用SQL数据库时遇到了麻烦,它在我的onCreate()方法中给了我一个错误,我对数据库工作和android编程都比较陌生,所以我真的很困惑。
Here is my code 这是我的代码
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL("CREATE TABLE " + DATABASE_TABLE1 + " (" + KEY_ROWID
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_TITLE
+ " TEXT NOT NULL, " + KEY_PATH + " TEXT NOT NULL, "
+ KEY_TAGS + " TEXT NOT NULL);");
}
the error i am getting from logcat is this 我从logcat得到的错误是这个
E/AndroidRuntime(1537): android.database.sqlite.SQLiteException: unrecognized token: "'s (_id INTEGER PRIMARY KEY AUTOINCREMENT, video_title TEXT NOT NULL, path_in_system TEXT NOT NULL, search_tags TEXT NOT NULL);": , while compiling: CREATE TABLE Video's (_id INTEGER PRIMARY KEY AUTOINCREMENT, video_title TEXT NOT NULL, path_in_system TEXT NOT NULL, search_tags TEXT NOT NULL);
You cannot (normally) name a table Video's
. 您(通常)不能为表格Video's
命名。 Maybe you just meant to use Videos
? 也许您只是想使用Videos
?
However, if for any reason you absolutely need the table to be named Video's
(with the apostrophe) or any other non-standard identifier, then you can use either double quotes or brackets. 但是,如果出于任何原因您绝对需要将该表命名为Video's
(带有撇号)或任何其他非标准标识符,则可以使用双引号或方括号。 For example, this does work: 例如,这确实有效:
db.execSQL("CREATE TABLE [" + DATABASE_TABLE1 + "] (" + KEY_ROWID ...);
as does this: 就像这样:
db.execSQL("CREATE TABLE \"" + DATABASE_TABLE1 + "\" (" + KEY_ROWID ...);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.