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
3
votes
1 answer

what is the official / right way to make the entity and Dao file when using kotlin

trying to use room with kotlin, not find official document. Here is some finding from the fails. made it work for the simple cases but still not sure if it is the right way, so post it here and hope someone knows the office / right way to do it with…
lannyf
  • 9,865
  • 12
  • 70
  • 152
3
votes
2 answers

Primary key from parent class using Room?

I am using Android Architecture Components. Hence using Room 'ORM'. I have a class EQPreset that has a member String presetName. This class has a child class called UserDefinedEQPreset and it contains an int[] arr. I have declared the child class…
3
votes
0 answers

Custom object passed in a method in DAO class Room persistence

I am trying to replace my database with Room persistence I've a method which accept a Custom Object and return the id of that row is in database /** * This method return -1 if there is not any classInfo other wise return * the id of the…
Sunny
  • 14,522
  • 15
  • 84
  • 129
3
votes
1 answer

Getting Fata signal 11 when trying to use Observable

I'm working on a project trying for the first time Kotlin, RxJava 2, and the new android architecture components. I'm trying to execute a delete method from Room on separate Thread and I'm getting ERROR: Fatal signal 11 (SIGSEGV), code 1, fault addr…
3
votes
0 answers

How to initialize room persistent library database with retrofit retrieved model information?

im having trouble understanding how to use retrofit with android persistent library room. Lets say i have the following model entity defined: Entity(tableName = MY_EVENT_TABLE) public class Event { public static final String TABLE_NAME =…
j2emanue
  • 60,549
  • 65
  • 286
  • 456
3
votes
2 answers

Room DataBase not implemented

I am trying out the new Room ORM from googles Android Architecture Components, I followed the documentation but when i run my code i get java.lang.RuntimeException: cannot find implementation for com.zeyad.usecases.app.UserDatabase.…
Zeyad Gasser
  • 1,516
  • 21
  • 39
2
votes
0 answers

Room 2.5.2 runtime crash - NoSuchFieldError: No instance field mDelegate of type SQLiteStatement

I'm trying to update the Room database library on an Android app I'm developing from version 2.4.3 to 2.5.2, these are the Room dependencies in my gradle.build file dependencies { val room_version = "2.5.2" …
M.Ed
  • 969
  • 10
  • 12
2
votes
0 answers

Android Room - DAO method returning Flow emits data only once for a composed object

I have two tables, Location and Weather. They have one-to-one relationship. Weather has a foreign key that keeps the id of corresponding entry in Location. @Entity(tableName = "location") data class Location( @PrimaryKey(autoGenerate = true) val…
Mehmed
  • 2,880
  • 4
  • 41
  • 62
2
votes
1 answer

How to drop a Room database?

How can I delete the Room database of my app? I've found the clearAllTables() method, but that's not what I want. Instead I really want to delete the database on user logout and start all over.
stefan.at.kotlin
  • 15,347
  • 38
  • 147
  • 270
2
votes
0 answers

Android room db migration delete from table all embedded columns

I trying to delete "@Embedded" object from some table by class MigrateFrom28To29 : AutoMigrationSpec example: @Entity data class A( @PrimaryKey var a: String, var b: String, @Embedded(prefix = "c_") var c: C ) data class C ( val a:…
Vadim Eksler
  • 865
  • 9
  • 24
2
votes
1 answer

Room create from asset + fallbackToDestructiveMigration recreating the database on each request

Using Room, I load my database from assets (an already populated database). I do plan to update the database content very often, so every time the version is increased, the old database the user has installed in their storage must be removed and…
2
votes
1 answer

Why is the key not generated in the SQL Room?

User Code: @Entity public class User { @PrimaryKey(autoGenerate = true) public Integer uid; @ColumnInfo(name = "first_name") public String firstName; @ColumnInfo(name = "last_name") public String…
kirialium
  • 31
  • 4
2
votes
2 answers

Why does @PrimaryKey val id: Int? = null works when creating a Room entity?

I'm following a tutorial on how to create a note app using Jetpack Compose. This is the link for the tutorial. There is a point in the tutorial that he creates this entity: @Entity data class Note( val title: String, val content: String, …
2
votes
0 answers

Instance creation error : could not create instance for 'AppDatabase. Cannot find implementation for AppDatabase. AppDatabase_Impl does not exist

I'm having an issue related to the use of Koin DI together with Room DB. I created all the needed components for Room as follows: @Dao interface CharacterDAO { @Query("SELECT * FROM character") suspend fun getAll(): List
Santo
  • 61
  • 4
2
votes
1 answer

[Android][Room] Storing Sealed classes into Room Databse

There is no default support for inserting or retreiving kotlin sealed classes into the ROOM database. Enums could be easily work, but not SEALED classes. Below is my example for a DOWNLOADSTATUS seal @Entity(tableName = "SomeTableName") data class…