OrmLite can create table successfully but cause error after insert a record
In my project I used OrmLite to create a table named OrderItem, in logcat it create table successfully but when I try to insert a record it show an exception. I would like to know why this is happening? Please my logcat. Thanks After create OrderItem 09-12 07:30:13.075: I/TableUtils(22428): creating table 'OrderItem' 09-12 07:30:13.085: I/TableUtils(22428): executed create table statement changed 1 rows: CREATE TABLE `OrderItem` (`custom_taste` VARCHAR , `order_id` INTEGER , `name` VARCHAR , `id` INTEGER PRIMARY KEY AUTOINCREMENT , `food_id` INTEGER , `quantity` INTEGER ) After insert a record to OrderItem it show food_id column not found. In above logcat food_id column is created. 09-12 07:32:00.885: E/SQLiteLog(22428): (1) table OrderItem has no column named food_id 09-12 07:32:00.905: W/System.err(22428): java.sql.SQLException: Unable to run insert stmt on object com.expresspos.mm.object.OrderItem#40ddbdd8: INSERT INTO `OrderItem` (`custom_taste` ,`order_id` ,`name` ,`food_id` ,`quantity` ) VALUES (?,?,?,?,?)
While I am waiting for somebody's answer, I searched some solution to my qestion. This link is helpful https://groups.google.com/forum/#!topic/ormlite-android/k-i1MnaL-aQ. Here is my solution, // some set of alter table statements to tweak the schema orderItemDao.executeRaw("ALTER TABLE `OrderItem` ADD COLUMN food_id INTEGER DEFAULT 0;"); I didn't think about that I need to alter OrderItem table when adding a column. I have to alter table because that database I have preferred is already been created. Thanks
Use HC-06 Bluetooth Chip With PIC16F887?
How to solve this kind of Android ANR(system_server first process)?
How to include a .so library and .c files in Android Studio 1.5
Assign value to a variable in a string query at run time
Android: EditText input validation
Which directory is secure to save the data
ActionBar won't remove
Gradle finished with non-zero exit value 2?
Which values to update to in android studio
Activity Reload every time
Android Studio - saving user data
How to use Android proguard only with the optimize function
Creating a Serializable ArrayMap
Adding Intent Filter using manifest merger in Unity3d
Ionic Framework Build for IOS on El Capitan - Build Error (GCC?)
Android Setting Alarm from Fragment