Android Sqlite数据库常见问题总结

来源:互联网 发布:软件外包合同范本样本 编辑:程序博客网 时间:2024/05/15 22:42

当在SQLiteOpenHelper的实现类的onCreate中创建表格时,会遇到下列问题

 @Override    public void onCreate(SQLiteDatabase db) {        db.execSQL("create table" + CrimeTable.Name + "(" +                "_id integer primary key autoincrement," +                CrimeTable.Cols.UUID + "," +                CrimeTable.Cols.TITLE + "," +                CrimeTable.Cols.DATE + "," +                CrimeTable.Cols.SOLVED +                ")"        );    }

控制台打印的错误如下:

 Caused by: android.database.sqlite.SQLiteException: near "tablecrimes": syntax error (code 1): , while compiling: create tablecrimes(_id integer primary key autoincrement,uuid,title,date,solved)

错误原因是:The missing space is what caused the issue as you can see in your first line of error report:
所以最重要的一点是:So yes the space between TABLE and TABLE_NAME is important !!!(在TABLE和TABLE_NAME中间的空格一定不要忘记)

0 0
原创粉丝点击