As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [android-room]

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

Filter by
Sorted by
Tagged with
1 vote
0 answers
23 views

how to make an api if i have a database without data

I am very new to the backend and I need your help since I do not understand how a database communicates with the api. I have developed a mobile app with java (I use the android studio IDE) and I was ...
wuad's user avatar
  • 111
0 votes
0 answers
6 views

Is it possible to use a Room database in an android Tile?

I am building an app specifically for watches, with it I'd like to have both a tile and a complication. In the tile I would like to show a simple chart of the users activity, or at the very least ...
Neglected Sanity's user avatar
0 votes
0 answers
24 views

Room causing build errors

I've spent hours trying to come up with a solution. Very non-descriptive error (for me at least). Here's the error: Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ...
Asim's user avatar
  • 6,933
1 vote
1 answer
36 views

How does android room stream query all the data in the table?

I want to upload data to the server through websocket, so I am looking for a way to use Room to stream query the data in the entire table. I guess return List is not a good solution? Suppose there are ...
SageJustus's user avatar
0 votes
0 answers
17 views

Updating Kotlin Room Database automatically from the API without need for user input

How can I update Room Database automatically, when changes are made from an API? This portion of the code works to update, however, changes are only made when I filter my list of items. I would like ...
DrewCodes's user avatar
0 votes
0 answers
26 views

Null Pointer Exception when creating a Room database in Android

I am encountering a Null Pointer Exception while attempting to create a Room database in my Android application. The exception occurs when executing the build() method of the Room.databaseBuilder(). I ...
Filler's user avatar
  • 83
0 votes
1 answer
17 views

Android room: Don't override properties with null

class ArticleResponse( val id: Int, val previewContent: String ) fun ArticleResponse.mapToEntity() = Article( id = id, previewContent = previewContent, content = null ) class ...
Daniel's user avatar
  • 380
0 votes
0 answers
18 views

Is posible to change TimeZone of Room db in Android?

I currently have the following query in a Room database: @Query("select * from items WHERE DATE(timestamp, 'unixepoch')=:date ORDER BY timestamp ASC") fun getItemsByDate(date: String): ...
Melk90's user avatar
  • 371
0 votes
1 answer
31 views

Insert in SQLite faster using single Android Room transaction rather than multi transactions

By default, each method annotated with @Insert, @Update, or @Delete in DAO class will be executed within its own transaction and additional transactions are queued and executed on a first come, first ...
oguzata's user avatar
  • 33
1 vote
1 answer
25 views

Room database is working fine in Debug build but not working in Release build

Hi StackOverflow community, recently I have updated my Android project to Gradle 7.5 and Kotlin to 1.7.20. But since then I couldn't get the Room DB working in the release build. On Debug build it ...
Wiki's user avatar
  • 11
0 votes
1 answer
58 views

Room - Not sure how to convert a Cursor to this method's return type (java.lang.Object)

I'm creating a project with Room and I have the following codes: For my entity class: import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.PrimaryKey @Entity("matches&...
Leonardo Sibela's user avatar
0 votes
1 answer
27 views

How to Upsert item with unique index in Android Room?

I have JSON data in an API host like this "product": { "barcode": "2489752310342", "productName": "Trench coat", "priceList&...
oguzata's user avatar
  • 33
1 vote
1 answer
30 views

Use TypeConverter or break single class into multiple classes?

I'm trying to implement Room in an app that is already in production. My question is how do I want to handle Entities with ArrayLists most efficiently in a Room Database? I know my way around SQL and ...
JonR85's user avatar
  • 670
0 votes
1 answer
20 views

android studio: error: Cannot figure out how to read this field from a cursor

I have a scenario where i read data from a Room database in a special read object. meaning because i wanted to read from 2 table (join) and put the result in 1 object i created a seperte read object ...
Michel's user avatar
  • 73
2 votes
0 answers
45 views

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") ...
Mehmed's user avatar
  • 2,850
0 votes
2 answers
39 views

ListenableFuture: Not sure how to handle insert method's return type

From the documentation from Google: // Returns the number of users inserted. @Insert(onConflict = OnConflictStrategy.REPLACE) public ListenableFuture<Integer> insertUsers(List<User> users);...
user1785730's user avatar
  • 3,170
1 vote
0 answers
31 views

How to handle LoadType.Prepend in android Paging 3?

I'm trying to create a timeline list similar to a Twitter client using Android Paging 3 and Room library, but I'm facing some issues. According to the loadType in the Paging RemoteMediator, it can be ...
Afterglow's user avatar
  • 325
0 votes
0 answers
24 views

Flow not emitting any value

I have a sql query in Room which checks whether table is empty or not and returns Flow. It emits for the first time but not after inserting in table Dao: @Query("SELECT EXISTS(SELECT 1 FROM ...
Ansh T's user avatar
  • 13
1 vote
1 answer
30 views

Get Context in Android Room Migration

Get Context in Android Room Migration: In my Migration i want to get context to read some files from assets: @Module @InstallIn(SingletonComponent::class) object PersistenceModule : Application() { ...
Lemkinator's user avatar
-2 votes
0 answers
19 views

How to Store and Retrieve Image from Room database? [duplicate]

I have already started to make a simple application, there are such tables, what type do I need to enter for images in order to add them to the database? And one more question, how to make it so that ...
Ramzab Shikarno's user avatar
0 votes
2 answers
30 views

Android ROOM - Kotlin - Insert return value with multiple parameters of different type

With Insert Room datbase, I need insert two entity at one time. @Transaction @Insert(onConflict = OnConflictStrategy.IGNORE) suspend fun insertChemicalChemistry(baseChemical: BaseChemical, langInfo: ...
VIL's user avatar
  • 3
0 votes
0 answers
21 views

How can I optimize RecyclerView loading when using Android Room database and Paging 3 library?

I'm building a chat application. I am using the Android room database and Paging 3 lib. now while I am loading the chats in the chat details recyclerview. It is taking a long to load for the first ...
Somnath's user avatar
  • 11
0 votes
2 answers
34 views

Changing LiveData WHERE clause

I have a Room Dao method like this: @Query("SELECT * FROM stuff WHERE x == :y") LiveData<List<Stuff>> getStuff(int y); And in my ViewModel I have this variable: LiveData<List&...
user1785730's user avatar
  • 3,170
0 votes
1 answer
26 views

Dao class must be annotated with @Dao - java.util.List

How I resolve this problem in my project Despite in Dao Class exist annotated @Dao on interface notes.kt import androidx.room.Entity import androidx.room.PrimaryKey import androidx.room.ColumnInfo @...
Fatemeh Shoja's user avatar
0 votes
1 answer
46 views

Kotlin - Room Database - POJO - Entity class must be annotated with `@Entity`

I have this error when I use the code below, the goal is that I have a data class that contains a House object which is referred to the House entity which serves as parent. Additionally the entity ...
Lulu97's user avatar
  • 1
0 votes
1 answer
32 views

Room's DAOimpl not generating correctly

I am trying to use Room library to access a DB, but DAO implementation is not generating well. In my DAO interface i have: @Query("SELECT b.position,b.name,b.capacity,b.currentAmount, it.name ...
Dioswison's user avatar
0 votes
2 answers
48 views

How do I retrieve the correct user ID when creating a login-enabled note-taking app using Jetpack Compose and Room Database in Android Studio?

The inability to retrieve the correct user ID, which prevents me from assigning a note to the logged-in user. Hey, for the past two weeks, I've been struggling with an issue while creating a login-...
deadmouze's user avatar
0 votes
0 answers
16 views

RecyclerView items dissapear after transition to another fragment

RecyclerView doesn't show items that I observe from database when I'm lauching my app. They only appear when I return from AddSceneFragment and dissapear after switching to different fragment. This is ...
Bitaghd's user avatar
1 vote
0 answers
17 views

How to update a Hilt provided singleton?

In my AppModule I have this: @Singleton @Provides fun provideRoomDatabase(@ApplicationContext applicationContext: Context) : AppDatabase { return Room.databaseBuilder( applicationContext, ...
stefan.at.kotlin's user avatar
0 votes
1 answer
20 views

How can I know if RoomDatabase.clearAllTables() has finished?

RoomDatabase#clearAllTables() returns Unit. So, how can one know when it has finished? Is that possible at all? Update: That is the generated code taken from AppDatabase_Impl.java @Override public ...
stefan.at.kotlin's user avatar
2 votes
1 answer
29 views

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's user avatar
-1 votes
2 answers
41 views

How to set maximum size of Room database

I'm trying to set the maximum size of Room database. I found that I can set maximumSize in database onCreate() callback, but then when I'm checking this value in onOpen() callback it is not changed. ...
pmw_14's user avatar
  • 9
0 votes
1 answer
33 views

How to change data in a room database from a JSON file

I have a main table and I need to completely replace all the data in it with file data from JSON, for example, there are 20 rows in the table, and 15 rows in JSON, how to write or replace rows in the ...
Gelio's user avatar
  • 1
1 vote
1 answer
33 views

How can I add the sencond sort item when I use CASE to require parameter for SQLite with Room in Android Studio?

I have read the article The Code A can work well in Android Studio. At present, I hope to sort records by starred desc first, then by createdDate desc, so I replace Code A with Code B. The Code B can ...
HelloCW's user avatar
  • 1,131
0 votes
1 answer
10 views

android room best practise - duplicate entities

I have an existing app that uses a folder-object for it's model. The data is generated on the fly and so there was no persistence. Now i am updating this app to use room as a database, to store said ...
hinton's user avatar
  • 1
-1 votes
1 answer
13 views

Android: why Room removes parent if I remove only child?

I'm working with Room for an android application. @Entity(tableName = "author") data class AuthorEntity( @PrimaryKey @ColumnInfo(name = "authorId") val authorId: String, @...
Sbirulinu's user avatar
0 votes
1 answer
14 views

Integrating SQLCipher latest version v4.5.4 with android kotlin project

I could find a lot of integration samples for old versions of SQLCipher with android and it also works. But I need to integrate latest version of SQLCipher like v4.5.4 because it mentioned that that ...
Dhana_prakash's user avatar
2 votes
0 answers
28 views

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, @...
Vadim Eksler's user avatar
0 votes
0 answers
9 views

How to write type converter for nested object in android

I tried to write type converter for following object but its not working. data class GlobalStatus( val ai: UseCaseStatus, var user: UseCaseStatus, val global: ...
Ragini's user avatar
  • 332
0 votes
1 answer
36 views

Compiler fails if having both `@Insert` and `@Upsert` in Room DAO (Jetpack Compose)

I have the following code: package com.example.secondcompose.dao import androidx.room.Dao import androidx.room.Delete import androidx.room.Insert import androidx.room.OnConflictStrategy import ...
Szymon Marczak's user avatar
0 votes
0 answers
7 views

how to use Rxjava with room and use mvvm with LiveData //How do I switch usage from executorService to rxjava?

enter image description here What is the best approach to replace the use of executorService with RxJava in a repository class that is used with ViewModel and LiveData in an Android app?
kareem mohamed's user avatar
0 votes
1 answer
51 views

Passing data between two different Navigation Graphs

I have two different Navigation Graphs in my app. The first one has 3 fragments: fragment with the list of created projects, fragment where i create new projects and the support fragment which has the ...
Bitaghd's user avatar
0 votes
2 answers
84 views

What will happen when multiple suspend functions in background service update different rows of SQLite DB simultaneously using Room in Android Studio?

In my Android Studio project, I am utilizing SQLite with Room for database operations. The background service contains several suspend functions that are responsible for updating rows within the ...
HelloCW's user avatar
  • 1,131
0 votes
0 answers
11 views

Room with Flow and RecyclerView with ListAdapter

I have a Large Dataset in Room and it want to show it on RecyclerView but the app freezes due to huge dataset. I am using Dao -> Repository -> ViewModel -> Activity/Fragment (To show in ...
Dushyant Kumar Behera's user avatar
-2 votes
0 answers
26 views

how to make few Dao for room database

I have several database tables which have similar methods (insert, delete, update) can I make several daos and thus repositories and viewModel to access the database for example databaseViewModel....
Davanok's user avatar
  • 59
0 votes
1 answer
27 views

NullPointerException while retrieving data from room

I have 3 entitites (Location, Current and Forecast) with following relationships: 1.) Location - Current (one-one) 2.) Location - Forecast (one-one) Now to retrieve data from it i wrote a query @...
Ansh T's user avatar
  • 13
0 votes
1 answer
49 views

Will SQLite database be locked when some suspend function to operate it in Android?

I use SQLite with Room in my Android Studio project. There are some suspend functions to operate a SQLite database, some suspend functions in background service to modify records. Will the SQLite ...
HelloCW's user avatar
  • 1,131
1 vote
1 answer
38 views

How can I write a query which require parameter for SQLite with Room in Android Studio?

I know I can use Code A to a accept a parameter for id I hope to accept a order by parameter in Code B, how can I do? You know there are four methods for order by , there are : SELECT * FROM ...
HelloCW's user avatar
  • 1,131
0 votes
0 answers
10 views

Restrict the access of room database to application layer

Currently, I am working on an SDK(library project) and using the Room database. I want to have access restrictions so applications using SDK can not access the SDK database. Any help would be ...
Rahul Chaudhary's user avatar
0 votes
0 answers
14 views

How to insert a record from ROOM into a Home Screen Widget with Clance

I'd like to insert a record from my ROOM database into a Home Screen Widget. I've added the receiver into the Manifest and created a XML provider. When I run the App and try to add the widget to my ...
Mik.Fasoli's user avatar

1
2 3 4 5
134