错误信息:
android.database.sqlite.SQLiteException: near "transaction": syntax error (code 1): , while compiling: **create table transaction ( _id integer primary key autoincrement, amount real, type varchar(20), date integer)
我的应用存储由自动生成的 ID、花费的金额、支付类型和日期组成的货币交易。我的应用程序编译正常,但是当我尝试运行创建数据库的 Activity 时,应用程序崩溃并显示上述消息。据我所知我的 SQL 语句是有效的,任何人都可以提供任何可能是什么原因的见解吗?
Java 代码:
db.execSQL("create table transaction (" +
" _id integer primary key autoincrement, amount real, type varchar(20), date integer)");
谢谢
最佳答案
transaction
是一个 SQLite Keyword .将您的表格命名为其他名称(例如,sales
)。
关于java - 为什么我的 SQL create 语句导致我的应用程序崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28069042/