android-room

How to get rid of Incremental annotation processing requested warning?

|▌冷眼眸甩不掉的悲伤 提交于 2020-03-12 07:00:11
问题 I have just started using android development and trying to use Room library. Since yesterday I am facing this warning message w: [kapt] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.lifecycle.LifecycleProcessor (NON_INCREMENTAL), androidx.room.RoomProcessor (NON_INCREMENTAL). I have tried to research and fix but unable to avoid this error here is my grale.build file. please suggest/advice what I am doing

Fatal Exception: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase

旧时模样 提交于 2020-03-05 06:53:30
问题 While updating Room database I get an error: Fatal Exception: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: ***************** at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1312) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1291) at android.arch.persistence.db.framework.FrameworkSQLiteDatabase

Unique constraint failed room database android

不打扰是莪最后的温柔 提交于 2020-02-14 19:12:51
问题 I'm facing a problem with Room database, when trying to use insert method that I declared in Dao Class to write a data into database this error shows up: Unique constraint failed Any idea way? Dao Class @Dao public interface TaskDao { @Query("SELECT * FROM task") List<Task> getall(); @Insert void insert(Task task); @Delete void delete(Task task); } AppDatabase Class @Database(entities = {Task.class}, version = 1) public abstract class AppDatabase extends RoomDatabase { public abstract TaskDao

Unique constraint failed room database android

試著忘記壹切 提交于 2020-02-14 19:12:15
问题 I'm facing a problem with Room database, when trying to use insert method that I declared in Dao Class to write a data into database this error shows up: Unique constraint failed Any idea way? Dao Class @Dao public interface TaskDao { @Query("SELECT * FROM task") List<Task> getall(); @Insert void insert(Task task); @Delete void delete(Task task); } AppDatabase Class @Database(entities = {Task.class}, version = 1) public abstract class AppDatabase extends RoomDatabase { public abstract TaskDao

How to select a specific column from room database given a specific parameter in room query?

落花浮王杯 提交于 2020-02-06 04:31:27
问题 How can I do the following? I want to select a specific column in my room query. This column will be specified by as a parameter in the query function. Imagine my database looks like the following: +----+---------+---------+---------+---------+ | ID | Column1 | Column2 | Column3 | Column4 | +----+---------+---------+---------+---------+ | 1 | 13 | 45 | 77 | 12 | +----+---------+---------+---------+---------+ | 2 | 5 | 34 | 67 | 7 | +----+---------+---------+---------+---------+ | 3 | 8 | 33 |

How to use Android Room on entities without fields?

与世无争的帅哥 提交于 2020-02-05 04:32:09
问题 I have java objects which are are backed by a HashMap and thus do not have plain fields which can be discovered via reflection. For example: public class City { private final HashMap<String, String> internalMap = new HashMap<String, String>(); public String getId() { return internalMap.get("id"); } public void setId(String id) { internalMap.put("id", id); } public String getName() { return internalMap.get("name"); } public void setName(String name) { internalMap.put("name", name); } } I want

How can I activate a Service outside Activity correctly?

北城以北 提交于 2020-02-01 07:46:26
问题 I am trying to build an app that will rely on a Webservice to work. To make it, I decided to follow the Model-View-ViewModel architecture together with the Repository pattern. I try to make this architecture inspired by the guidelines shown in Guide to App architecture, from Android Developer's Official Site. I use OkHttp library to consume the WebService, and Room for the phone's database. I made some testing to see if the app obtained succesfully the Data through the Webservice, from inside

How can I activate a Service outside Activity correctly?

眉间皱痕 提交于 2020-02-01 07:46:19
问题 I am trying to build an app that will rely on a Webservice to work. To make it, I decided to follow the Model-View-ViewModel architecture together with the Repository pattern. I try to make this architecture inspired by the guidelines shown in Guide to App architecture, from Android Developer's Official Site. I use OkHttp library to consume the WebService, and Room for the phone's database. I made some testing to see if the app obtained succesfully the Data through the Webservice, from inside

Android Room SQLite_ERROR no such table

佐手、 提交于 2020-01-31 02:26:27
问题 I'm trying my hand at using Android Room and after following this tutorial I'm getting the following error when i try to build the app: Error:(23, 27) error: There is a problem with the query: [SQLITE_ERROR] SQL error or missing database (no such table: screen_items) The name is fine and should exist. After making my changes I cleaned the project and made sure it was completely uninstalled from the device. In my Activity I'm initialising the things in onCreate with this line: db = AppDatabase

AutocompleteTextView with room

点点圈 提交于 2020-01-25 10:18:05
问题 I have a Room db and have created a model and viewModel. I was wondering how to make an autocompletetextview work with the database data and the viewmodel to filter the customer list as the user types ViewModel class CustomerVM : ViewModel() { private val customers: MutableLiveData<List<Customer>> by lazy { loadCustomers() } fun getCustomers(): LiveData<List<Customer>> { return customers } private fun loadCustomers() : MutableLiveData<List<Customer>> { return DataModel.getInstance().roomDb