任何人都可以破译这种方法有什么问题吗?日志说有语法错误,但我无法看到它。
以下是代码:
public void onCreate(SQLiteDatabase sqLiteDatabase) {
String createTable = "CREATE_TABLE " + MOVIES_DB + "("
+ TITLE + " TEXT, "
+ OVERVIEW + " TEXT, "
+ POSTER_PATH + " TEXT, "
+ RELEASE_DATE + " TEXT, "
+ ORIGINAL_TITLE + " TEXT, "
+ ORIGINAL_LANGUAGE + " TEXT, "
+ BACKDROP_PATH + " TEXT, "
+ ID + " INTEGER PRIMARY KEY, "
+ VOTE_COUNT + " TEXT, "
+ POPULARITY + " TEXT, "
+ VOTE_AVERAGE + " TEXT, "
+ ADULT + " TEXT, "
+ VIDEO + " TEXT, "
+ GENRE_IDS + " TEXT, "
+ HISTORY_USER + " TEXT, "
+ WATCH_LATER + " TEXT, "
+ FAVORITE_FLAG + " INTEGER DEFAULT 0"
+ ")";
sqLiteDatabase.execSQL(createTable);
}
它曾经工作过。我添加了FAVORITE_FLAG
,现在它还没有运行。我还在INTEGER NOT NULL DEFAULT 0
FAVORITE_FLAG
答案 0 :(得分:0)
正如@Juergen D所说,CREATE TABLE
占用空间而不是下划线。
查看SQLite的CREATE TABLE
Documentation。
顺便说一句;尽量把你的id
/ PK声明放在首位,因为这是常见的做法(也更合乎逻辑)
SQLite(SQL.js)架构设置:
CREATE TABLE MOVIES_DB(
"ID" INTEGER PRIMARY KEY,
"TITLE" TEXT,
"OVERVIEW" TEXT,
"POSTER_PATH" TEXT,
"RELEASE_DATE" TEXT,
"ORIGINAL_TITLE" TEXT,
"ORIGINAL_LANGUAGE" TEXT,
"BACKDROP_PATH" TEXT,
"VOTE_COUNT" TEXT,
"POPULARITY" TEXT,
"VOTE_AVERAGE" TEXT,
"ADULT" TEXT,
"VIDEO" TEXT,
"GENRE_IDS" TEXT,
"HISTORY_USER" TEXT,
"WATCH_LATER" TEXT,
"FAVORITE_FLAG" INTEGER DEFAULT 0
);
Insert into MOVIES_DB Values(1,"test","test","test 7",
"test","test 12","test","test","test","test","test",
"test","test","test","test","test",2);
查询1 :
select ID, TITLE, FAVORITE_FLAG from MOVIES_DB
<强> Results 强>:
| ID | TITLE | FAVORITE_FLAG |
|----|-------|---------------|
| 1 | test | 2 |