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
0 answers

Why am I getting error in the ArrayList while trying to put an instance in putParcelableArrayList?

So, I am trying to pass the data of all the saved cardviews into and show them in another fragment (ToLearnFragment.kt) so when I click on the star icon the data gets stored. so I am using room database for it, i have created the Room database and…
2
votes
2 answers

Flutter local database storage

Currently I'm creating a user registration criteria and it have three registration pages. For each completion of user registration page I want to store it in local storage. If the user closes the app before the 3 level of registration, I want to…
2
votes
1 answer

How do I make kapt gradle task showing errors in Kotlin code instead of generated Java code?

I'm using kapt for hilt and room. Whenever there is an error related to those libraries, kapt show me all errors in the generated Java code. How do I make it to show errors in Kotlin code instead? This is what it looks like in Android studio. Just…
acanthite
  • 71
  • 6
2
votes
1 answer

How to insert and query nested entities in Room database received from API that contains one to many relationships

I have an API that returns a DTO containing entities with the one-to-many relationships filled in a list. I'm struggling to figure out how work with that data in Room. I need to map this DTO to the corresponding Entities. I then need to insert them…
psclkhoury
  • 155
  • 3
  • 10
2
votes
0 answers

Which is the best approach for an app with multiple users using Room database?

I'm developing an app (Android, Kotlin) that allows the user to register different documents with specific information in Room database. I'll implement in the app to only be able to display the files registered if the user is logged in. It concerns…
Tods
  • 37
  • 6
2
votes
1 answer

Jetpack Compose: calling action inside LauchedEffect blocks UI anyway

I am trying to do some stuff on background and then displaying it to the user, but for some reason this does not work as it should and I am not sure what I am doing wrong. It is an app with possibility to encrypt images and storing them on…
2
votes
1 answer

Room Java - Is it possible to run transaction in interface?

I'm using room framework in my Android Studio project. I'm trying to create a transaction inside of an interface. I already read documentation from here: https://developer.android.com/reference/androidx/room/Transaction I know that we should create…
Tholvnar
  • 43
  • 5
2
votes
1 answer

What is the proper way to update list state after inserting an item via a repository in Compose?

I have a Room app which displays a list of presets, and the user has the option of adding them by pressing a 'New Quick Preset' button: Code for inserting new item into Room database (in ViewModel): fun insertQuickPreset(quickPreset: QuickPreset) { …
2
votes
1 answer

Room creating three or four relationship between tables

I am trying to achieve the following: I am working with Android Room. In code: @Entity(tableName = "BookReadingSchedule") data class BookReadingSchedule( @PrimaryKey @ColumnInfo(name = "schedule_id") val id: Long = 0, val name:…
Alix Blaine
  • 585
  • 2
  • 16
2
votes
0 answers

Android Room Hilt providing Database and Dao not working with return

Can somebody explain why my code crashes when providing RoomDatabase and Dao like this: @Module @InstallIn(SingletonComponent::class) object AppModule { @Singleton @Provides fun provideDatabase(@ApplicationContext app: Context):…
Matúš Ravas
  • 63
  • 1
  • 4
2
votes
1 answer

Flutter Drift library inconsistency found while naming table and doing migration

I want my table names to be specific as I am migrating from Native Android Room database to Flutter using Drift library for database. Room take a table name i.e. class name and creates a table: e.g. the following will create table 'User' with field…
Damandroid
  • 756
  • 9
  • 31
2
votes
1 answer

Kotlin Android lazy Class initialisation inside Object persist after killing App

I initialise an Object called DataSource inside a ViewModel. This object contained a lazily initialised class called ServerCalls. The ServerCalls class had a class scope reference to a token which after a user logged out was cleared from…
Hmerman6006
  • 1,622
  • 1
  • 20
  • 45
2
votes
2 answers

ROOM Dao ERROR: Not Sure How to handle insert method's return type & Not Sure how to handle delete method's return type

I am giving the classes whatever I created and ,and where the error is showing. I am unable to understand the error. DAO package com.example.grocerylist import androidx.lifecycle.LiveData import androidx.room.* @Dao …
2
votes
1 answer

Insert Query Room OnConflictStrategy.REPLACE

I want to replace the old product list and insert new product list even if the primary key of old and new product list not same. Interface: @Dao interface ProductDao { @Insert(onConflict = OnConflictStrategy.REPLACE) fun…
SasidharanIOS
  • 252
  • 1
  • 3
  • 12
2
votes
1 answer

Optimize Room database migrations

In migration (3,4), I delete table TableA and create two new tables TableB and `TableC. static final Migration MIGRATION_3_4 = new Migration(3, 4) { @Override public void migrate(SupportSQLiteDatabase database) { …
Abdo21
  • 498
  • 4
  • 14