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
Code for android that would use a compass to point to a specific Longatude and Latatude?
implementing YouTube API v3 in ViewPager Android
Cannot find symbol class on Butter Knife generated code
java.lang.IllegalStateException: Layout state should be one of 100 but it is 10
Adding same views to RelativeLayout multiple times
How to use Observables, RxJava and Android to access a Webapi?
Create a transaction to update multiple places in Firebase Database
Notification does not displayed on wear, but displayed on hand held
Android emulator resolution issue after updating android sdk tool
IndexOutOfBoundsException when trying to populate data in recyclerview from two json arrays in a one json object
Count child nodes and show on parent node in Android Expandable ListView
Is it possible to set default transition animation for all application in AOSP?
Align menu item at Navigation to the right side in android
Recycler view only updating first visible position with onBind code?
Most efficient method of creating a local notification system with Firebase
Dagger 2: How properly to reuse dependency - how to design components and scopes?