Questions tagged [android-room]
For questions related to Android Room Persistence Library (which is a part of Android Architecture Components)
5,975
questions
0
votes
0
answers
6
views
how do i correctly implement safeargs?
I am trying to follow a tutorial in order to implement and use a room database YouTube-link.
My problem is that my gradle files look so different compared to what is shown in the video that I have no ...
0
votes
0
answers
7
views
Return value from SINGLE_EXECUTOR while inserting data into room
I am trying to return Long from SINGLE_EXECUTOR function while inserting data in room but unable to do this I have tried alot
this is my executor
fun executeThread(f: () -> Unit) {
...
-1
votes
1
answer
23
views
When first add recycler view item, it will not delete on the first delete button, but when recheck it after delete press, it will delete, why?
I have an app where alarm items are added to my recycler view. They are added to a list and added to a room database. The recycler view updates from the list. When I first add say 3 alarms to the view,...
0
votes
1
answer
18
views
ROOM database: insert static data before other CRUD operations
I have a question about adding static data (taskPriority) to the database. From what I understand, the right way to insert data on database create is to use RoomDatabase.Callback. However, when the ...
0
votes
1
answer
32
views
Chaining and mapping kotlin flow
I'm trying to get a result from a flow, that retrieves a list from a room database, and then trying to map the list with another flow inside from another database operation, but I don't know if it is ...
-1
votes
2
answers
25
views
Android. Weird behavior when deleting a column in room (Foreign key)
I have an android note pet project with room database where I store files and related pages to the file. One to many relationship:
@Entity(tableName = NotepadDatabase.FILES_TABLE)
data class ...
0
votes
1
answer
30
views
Room Database problem with Query in Dao class
So in my room query i get error Cannot resolve symbol 'photos' and Cannot resolve symbol 'image_id' like room doesn't recognize this table and field the error occurs just after implementing MyImages ...
0
votes
0
answers
11
views
How do I execute local/remote sync commands sequentially? Android Architecture, Retrofit and Room database
I have a few tables I need to sync between my remote database and my local room database.
Basically, if remote users add to the remote tables and local users add to the local tables, there are now ...
0
votes
0
answers
14
views
RecyclerView not populating from Room DB ViewModel
I'm trying to show data from db to RecyclerView from ViewModel, but unable to see the list on home screen. I'm new to MVVM model.
I've implemented POJO class for product and implemented Room DB using ...
0
votes
1
answer
29
views
Deserialize json of recursive nested objects
I am trying to deserialize json like this using gson and then insert it into DB using Room but unsuccessfully:
[
{
"id": 1,
"name": "category1",
"...
-1
votes
0
answers
29
views
pls, can someone help on how to solve this error?
if have a dao
@Dao
interface LetterDao {
@Query("SELECT * FROM `letter.db`")
fun getLetters(query: SupportSQLiteQuery): DataSource.Factory<Int, Letter>
...
}
error:
Query ...
0
votes
1
answer
38
views
Confusion on Room Auto Migration with NOT NULL column but no defalut value
Short Version
After updating Android-Room version from 2.2.x to 2.4.x, I decide to use auto-migration feature to help me write less code. So I want to deprecate all migration written manually and use ...
1
vote
0
answers
22
views
Accessing the Room database from ViewModel
I'm about to refactor my app to use a ViewModel. This is the database:
@Database(entities = [TimeStamp::class], version = 1, exportSchema = false)
abstract class RoomDB : RoomDatabase() {
abstract ...
-1
votes
1
answer
30
views
Get a single object from a Room query in a background thread and use it in the view. Android/Kotlin/MVVM
In my current solution to this I use coroutines and return a MutableLiveData in the ViewModel that the view .kt class observes.
DAO function:
@Query(
"SELECT workout_name FROM workout_table &...
0
votes
1
answer
50
views
How to properly use the result from a get query from a Room database
In my app I have a list of workouts, and at one point a want to get the name of one workout using its id in the Room database. For this, I made a SQL query in the DAO class to get the workout name ...
0
votes
1
answer
31
views
Room database query for several Entities
Could you please help me? I try to get data from TMDB via Retrofit2 to Room database and display it in Recyclerview. I make 3 api calls to get data about popular movie id/poster/overview/title/genres, ...
0
votes
0
answers
40
views
How to share data from Room Database?
I'm doing an app using MVVM architecture and Room database. In database is one table in which are information about tasks:
@Entity(tableName = "task_table")
public class Task {
@PrimaryKey(...
2
votes
0
answers
22
views
How to add programmatically generated imageviews to room database
How can I add multiple imageviews generated programmatically from linearlayout to room database. I have used byte for it but I can only store one image. I want to store all images in the same row
...
-1
votes
0
answers
23
views
Calculate the total price from recycler view
Excuse me, so this chance I'd like to calculate the final total price that calculates from the sum of total price (this calculation is from quantity per item multiplied by item price) for each item in ...
0
votes
1
answer
16
views
How to set Nullable primary key in Room Database Android
While migrating sqlite database to RoomDatabase I am facing issue(java.lang.IllegalStateException: Migration didn't properly handle) with primary key.
SQLite code:
@Override
public void onCreate(...
0
votes
0
answers
29
views
how to save custom view state in android studio
I'm developing an application which has drawing functionality. I want to save my drawing in the room database with the view(whatever users draw). It should be restored when the user clicks on his ...
0
votes
0
answers
24
views
Room Database Android Entities and POJOs must have a usable public constructor. You can have an empty constructor or a constructor whose parameters [closed]
**
package com.arrayofsilicon.myapplication
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "DataTable")
data class MyDataTable(
@PrimaryKey(autoGenerate = ...
0
votes
1
answer
12
views
Android room data relations
I have multiple object tyes inside a parent class.Say I have a College class as below
data class College(
@PrimaryKey
val id:String,
val name: String? = null,
val description: String? =...
0
votes
0
answers
40
views
android no implementation room 2.4.2
Unable to install version room > 2.3.0.
I specify the version above - I do syns now gradle (does not show errors).
When compiling the project, it writes that it is not possible to find libraries ...
0
votes
1
answer
38
views
Execute in a separate thread
I have a small application which is responsible for intercepting requests and responses. Forms them into a package and can save them to local storage. I'm using the Room library to save data locally.
...
0
votes
0
answers
21
views
SQlite (Room) Trigger: three queries
I have the following trigger:
database.execSQL(
"CREATE TRIGGER IF NOT EXISTS update_item1" +
" BEFORE UPDATE" +
" ON ...
0
votes
1
answer
28
views
Room DAO to Repository class mapping [closed]
The Guide to app architecture states that "You should create a repository class for each different type of data you handle in your app. For example, you might create a MoviesRepository class for ...
0
votes
0
answers
19
views
Efficiency and memory requirements of DataViewModel and Room Database
When implementing a Room ORM for sqlite databases, I am following the practise of making
a singleton AppDatabase class extending RoomDatabase
a Repository class with getters and setters interacting ...
0
votes
2
answers
21
views
LocalDatabase_Impl does not exist
@Database(entities = [AepsBankTokenModel::class], version = 1)
abstract class LocalDatabase : RoomDatabase() {
abstract fun aepsBankTokenDao(): AepsBankTokenDao
companion object {
private var ...
0
votes
0
answers
9
views
How to add query to room database and retrieve to recylerview
I have event database and adapter. I want to show event based on selected date. How can I solve it?
private fun setEventAdpater(date:String) {
val linearLayoutManager=LinearLayoutManager(this,...
-1
votes
0
answers
16
views
Update multiple rows of single column with different value in single query?
How to make a query for updating different rows but single column(same column) with a single query. I found many solutions related to this problem but no one solve my problem.
Let's suppose the table ...
0
votes
1
answer
84
views
Is the collect function of Flow a block function in Kotlin?
I hope to delete records by Id list and relative files with Room.
I find the files can be deleted and the records can't be deleted when I run Code A
I find the records can be deleted when I run Code B....
2
votes
1
answer
25
views
Get tree of ancestors from a SQLite table with Room and Flows
This is very tricky for me because I don't know if it can be done with a SQLite query or by recursively calling some function. It gets complicated because I also use Flow and LiveData with ViewModel
...
0
votes
1
answer
15
views
How to link deletion in room data
I have two data base or two tables ex:one for matches and one for chat jn event section in match note that the all messages is inserted in one table mean that every chat of every match is inserted in ...
0
votes
1
answer
26
views
(Anrdoid) How to prepopulate the Room database
I made a screen like the current image.
Data such as A, B, C.. are currently being set by getting from the strings.xml resource file.
I am now going to use Room DB instead of strings.xml and I want to ...
1
vote
1
answer
25
views
Query method parameters should either be a type that can be converted into a database column or a List
package com.example.hand.data;
import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room....
0
votes
1
answer
31
views
Kotlin read from room database in fragment
I write an application with room database and I have a problem with reading data and use it in the mine thread.
consider tables as those:
Table1
| ID | Name |
| -- | ------ |
| 1 | first |
| 2 | ...
0
votes
0
answers
39
views
Sending an ID or an object as String to the next screen in Jetpack Compose?
I have 30 users displayed in a LazyColumn. On user click, I navigate forward to UserDetailsScreen. My question, is it better to pass the ID of the user and create another database (Room) call inside ...
0
votes
0
answers
25
views
Android MVVM - Where to place function/logic to generate timestamp/guid within room?
I am currently revising my first Android APP (shoppinglist) and trying to implement the mvvm patern.
To store the data I use room and have created a viewmodel, repository, dao and model class.
So far ...
-1
votes
0
answers
13
views
Need to retrieve image with name x from the images folder and then add it to a room database using kotlin offering reward
I need to take an image and then save it in a location, after i need to add that location to a room database, which i then use to display all the photos i have taken . Want to make a contact list ...
0
votes
1
answer
24
views
How to define and use a tag system for my TODO app in room database
I've got a simple TODO app, each TODO is stored in the room datase. But I want to add tags for these TODO's so that each TODO could have 0 or more tags and each tag is a siple string. So the question ...
1
vote
1
answer
66
views
Android custom keyboard suggestions
I am building a custom keyboard for android, the one that atleast supports autocomplete suggestions. To achieve this, I am storing every word that user types (not password fields) in a Room database ...
0
votes
1
answer
56
views
How to add/remove characters inside TextField?
I have a Room database with a table that holds users. Each user has an ID and a name. My goal is to change the name of the user based on the ID. Here is what I have tried.
I have an UsersScreen that ...
0
votes
0
answers
14
views
ByteArray is null in Room database when compressing to PNG
I have a field for my entity defined like this
@ColumnInfo(typeAffinity = ColumnInfo.BLOB)
var thumbnail: ByteArray? = null,
and I want to save a small thumbnail compressed as PNG (to keep ...
0
votes
1
answer
33
views
What to send as Content
In my application, I save data to Firebase and to local storage using the Room library. With Firebase, everything is clear to me. But with Rom I had questions. I can't figure out what to pass to the ...
0
votes
0
answers
12
views
Will Executor with handler cause memory leak in android
I am doing my DAO queries from Room Database inside Executors and updating the UI in handler.post() method. Is it considered a bad practice or is there any way it will cause memory leak?
@Override
...
1
vote
1
answer
41
views
Method exceeds compiler instruction limit
Before I wrote this question, i've searched in all proposed answers, "stackoverflow" shows me but nothing fit my case.
My problem:
I wrote Room migration to copy old data from a table and ...
0
votes
1
answer
27
views
Android Room parse before inserting
Imagine receiving from an endpoint an object like this
data class Foo(
val name: String,
val start: String,
val end: String
)
where the properties start and end are string in the format ...
0
votes
1
answer
34
views
How to remove ALL data from the database
I would like to remove ALL data from the database (with auto-increment values).
I use Room.
I have read in the documentation there is something like clearAllTables() but according to the documentation:...
-1
votes
1
answer
32
views
Get a list of Item with some other data (With the id of this data inside of the item)
I have some products in my app and user can create Space if he want.
In the home page, I'm showing all the product of the users. If the user has stored the product inside an space, in the home page ...