Add columns in the SQLite database creation statement, and an error is reported after running: no such column
On the premise of grammatical norms, i.e
//SQLite database creation, comma and space must be strict String CREATE_NOTE = "create table " + NotepadEntity.TABLE_NOTE + " (" + NotepadEntity.NOTE_ID + " integer primary key autoincrement," + NotepadEntity.NOTE_TITLE + " varchar not null," //此列为修改语句后增加 + NotepadEntity.NOTE_CONTENT + " text not null," + NotepadEntity.NOTE_CREATE_DATE + " text);"; SQLiteDatabase db; db.execSQL(CREATE_NOTE);
It still fails to compile because the SQLite create command has been executed once, and the database file already exists. Even if the statement is changed, it is not executed again
Solution:
Open the DDMS tool and locate the file Explorer “, navigate to the database file list in the project file (expand to/data/data/& lt; package name>/ databases)
(you can export the database file to the computer, and use SQLite database browser and other tools to check whether there are columns of data not created)
Delete the database file and its journal file, return to the project and run again. If the program detects that the database is empty, execute the create command and compile
At this time, export the database file under DDMS, view the list structure, create the new column successfully, and solve the problem
Similar Posts:
- Using SQLite to show undefined reference to ` SQLite3_ open’…
- Database “C:/Users/com/test” not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149
- Sqlite – constraint failed[0x1555]: UNIQUE constraint failed
- [Solved] string(81) “SQLSTATE[HY000]: General error: 1364 Field ‘content’ doesn’t have a default value”
- [Solved] MYSQL ERROR 1290 (HY000): The MySQL server is running with the –secure-file-priv option so it cannot e…
- [Solved] MySQL Add New Field Error: ERROR 1118 — Row size too large. The maximum row size for the used table type
- [Solved] Oracle :value too large for column “SCHEMA”.”TABLE”.”COLUMN” (actual: 519, maximum: 500)
- Postgres invalid command data recovery processing
- ORA-00980 synonym translation is no longer valid
- MYSQL ERROR 1005 (HY000): Can’t create table [How to Solve]