android-database
Room Using Date field
You’re converting from Date to Long (wrapper) and from long (primitive) to Date. I changed it to Long and it compiled. Besides, unboxing null in your converter produces a NPE. public class DateConverter { @TypeConverter public static Date toDate(Long dateLong){ return dateLong == null ? null: new Date(dateLong); } @TypeConverter public static Long fromDate(Date date){ … Read more
Android Room database transactions
As pointed out on documentation for Transaction, you can do following: @Dao public abstract class ProductDao { @Insert public abstract void insert(Product product); @Delete public abstract void delete(Product product); @Transaction public void insertAndDeleteInTransaction(Product newProduct, Product oldProduct) { // Anything inside this method runs in a single transaction. insert(newProduct); delete(oldProduct); } }
Database won’t remove when uninstall the Android Application
in Android 6.0, google added new feature called Auto Backup. when this option is on(default is on), Android system copies almost every directories and files that created by system, and upload it to user’s google drive account. When user reinstalls app, android automatically restore app’s data, no matter how it was installed(via Play store, adb … Read more
Room cannot verify the data integrity
When you first come across this message, you will most likely be working against an unreleased version of the database. If that is the case, most likely you should not increment the database version. Simply clearing app data will move you passed the exception. If you do not increment the database (recommended): You should clear … Read more
Ship an application with a database
There are two options for creating and updating databases. One is to create a database externally, then place it in the assets folder of the project and then copy the entire database from there. This is much quicker if the database has a lot of tables and other components. Upgrades are triggered by changing the … Read more