Questions tagged [android-room]

For questions related to Android Room Persistence Library (which is a part of Android Architecture Components)

Room provides an abstraction layer over SQLite to allow fluent database access while harnessing the full power of SQLite.

6786 questions
2
votes
2 answers

How to handle query method's return type room using Kotlin, Coroutines, ViewModel, LiveData

How to handle query method's return type room using Kotlin, Coroutines, ViewModel, LiveData the building is failed and I'm getting lots of errors that are pointing into my Dao class and the error is Error 1: Not sure how to handle query method's…
Bolt UIX
  • 5,988
  • 6
  • 31
  • 58
2
votes
0 answers

Equivalent of distinctUntilChanged for Room list results

Single type results from Room in Flow streams have an option to filter out unchanged results distinctuntilchanged, this works perfectly for single type results (ex. Flow, Flow, Flow, etc.) However, this is no longer the case…
Shadow
  • 4,168
  • 5
  • 41
  • 72
2
votes
1 answer

How to resolve "Entities and POJOs must have a usable public constructor"

I have seen this question several times on SO. however the solution doesn't seem to apply to my problem. I have a Kotlin data-class that is used as an Entity in Room @Entity(tableName = "training_session") data class SessionEntity( …
hba
  • 7,406
  • 10
  • 63
  • 105
2
votes
1 answer

cannot find implementation ( Room )

I have an issue with Room or idk actually where the problem is and I need help to find out where is the problem, I'm using Hilt DI, the moment that creating an instance of database it crashes here's my code Error E/AndroidRuntime: FATAL EXCEPTION:…
Eslam Ali
  • 27
  • 1
  • 10
2
votes
1 answer

Getting UNIQUE constraint failed: tbl_data.id (Sqlite code 1555 SQLITE_CONSTRAINT_PRIMARYKEY) error in android studio room

I'm getting this error while i have initialize the id as primary key and i added the unique attribute. Data class code : @Entity(tableName = "tbl_data" , indices = {@Index(value = {"id"}, unique = true)}) public class Data { …
Daniel Mohajer
  • 117
  • 2
  • 8
2
votes
1 answer

How to store hardcoded encryption master key in android?

I'm building an app that uses Room and I want to encrypt the db using SQLCipher which needs a master key to encrypt/decrypt the db. I don't want to get the master key from the user, I want to use 1 master key and store it on the device but as far as…
Moxx4
  • 21
  • 1
2
votes
2 answers

Why does Android 12 and room-paging now crash

I've updated my android application to target Android S and was made to add api 'androidx.room:room-paging:2.4.0-beta01' to my gradle build file. Now my app crashes with E/AndroidRuntime: FATAL EXCEPTION: main Process:…
Hector
  • 4,016
  • 21
  • 112
  • 211
2
votes
1 answer

Is it possible to use Android Room Database to create an R*Tree table?

I would like to continue using Room, but I see no way to create an Entity that uses rtree. There is @FTS3 and @FTS4 annotations but nothing for RTree that I see. Is it possible to create an Entity using R-Tree? I was attempting to do a migration…
user1230593
  • 243
  • 1
  • 3
  • 9
2
votes
1 answer

Android Room notNull field is expecting a null default value

i'm trying to add new attributes to my tables as shown here: @Entity( tableName = "invoices", indices = [Index(value = [...], unique = true)] ) data class Invoice( ... override val created_at: Long = 0, override var approved_at:…
AmSabba
  • 67
  • 5
2
votes
1 answer

How to add new data to android room database when updating app?

I'm making an android app with Room database. My plan is to prepopulate database with some initial data when it is installed on device, and user can edit it and insert new row on each table. New row id by users will start from, for example,…
2
votes
1 answer

Delete old table and create new one and prepopulate it - RoomDatabase

I am creating a simple android application in android studio with java. I have a roomdatabase db with a table named user that has four columns name, profession, age, description and I have prepopulated using a database that i made in sqlite…
2
votes
1 answer

isOpen function valid for Room database or SQLite?

Package androidx.room has this function where it should return if I'm connected to the database or not. But I want to make sure that this is the correct function for Room only and NOT SQLite, All I'm getting is false. /** * Returns true if…
Ahmad Albatsh
  • 314
  • 1
  • 2
  • 12
2
votes
2 answers

MyRoomDatabase_Impl does not exist

I am facing some issue using Room DB java.lang.RuntimeException: cannot find implementation for com.zeliot.roomtuto.db.NoteDB. NoteDB_Impl does not exist below is my app grale plugins { id 'com.android.application' id…
2
votes
3 answers

Room database RawQuery() is not work on "IN" and "NOT IN" clause

I have my one table like UserTable. @Entity public class UserTable{ @PrimaryKey(autoGenerate = true) private int userId; private String userName; private String userEmailId; // Below code is getter and setter of this…
Mayur Misal
  • 806
  • 10
  • 13
2
votes
1 answer

How to attach two or more sub queries in room database dao while those subQuery stored in variables

I am upgrading my old database to room database, while conversion from plain sql statement to room sql statement. I am facing issues from following scenario. Scenario I : I have stored sub query in variable like this String subQueryLocalAddress =…
Mayur Misal
  • 806
  • 10
  • 13