Questions tagged [android-room]

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

0
votes
1answer
14 views

Combine data from two tables in Room ViewModel

I have two tables in Room. OrganizationSensor id name type 1 water pump Pressure 2 pump Temperature OrganizationSensorReading id o_sensor_id measurement 1 1 ...
-1
votes
1answer
13 views

How to check Room database have entities or not?

I need to request to the server and pass data from my local Database whenever the app is started again. Now the problem is that when opening the app for the first time I know there are no entities how ...
0
votes
1answer
21 views

How do you retrieve a tree structure using Room and a ViewModel with LiveData for use in RecyclerView containing sub-RecyclerViews?

I'm trying to retrieve a list of items of which each item can also contain sub-items (tree structure) in a Room database. I want to use these items in a RecyclerView that, depending on if the item has ...
-1
votes
0answers
19 views

is there a way to load extensions on ROOM or a way to use math functions?

Room is based on SQLITE, in the documentation is possible to load extensions, even on DB Browser for SQLite theres a math extension and after loaded the query that i need works fine, i tried to ...
0
votes
1answer
21 views

SQLLITE move column and its data from TableA to TableB

i have two tables below table_a with columns (id, table_bId, name, address, postcode, allowedPermisions) table_b with columns (id, type, level, info) I want to create a migration strategy as we now ...
0
votes
0answers
17 views

can i use Roomdatabase datamodel for retrofit api?

In my project I'm using retrofit for api calls and roomdatabase for storage. I want to know if it's possible to use the datamodel of the object I have created in roomDatabase to make api calls with ...
0
votes
0answers
15 views

Recyclerview Scroll State save with Room and LiveData on ViewPager

I am Using the MVVM pattern with Room Database. In one of the Screen there are 3 Tabs with FragmentPagerAdapter viewPager. Now I am able to save and Retrieve from Database in My Fragments. But I also ...
0
votes
1answer
27 views

I am trying to get data from room database in arraylist but it shows only last record in android

I have room database in android. but when i am retrieving data from database and showing in expandable RecyclerView it shows only last records in my child list. there is one child ArrayList under the ...
1
vote
1answer
34 views

How to model a relational database that stores order details?

I am making a restaurant POS app for android and I am trying to decide the best way to model the database for it using Room ORM that ensures maintainability. My database needs, among a lot of other ...
0
votes
1answer
48 views

Room DB throwing SQLiteDatabaseCorruptException

In our application, we are using Room DB to store data locally. In some of the devices of the users we are noticing that DB is throwing SQLiteDatabaseCorruptException When we try to put a try/catch ...
0
votes
1answer
39 views

How to set RecyclerView OnClickListener in Fragments?

I'm trying to start a new Fragment that shows the details of the item that was clicked on in the RecyclerView. I've tried this in Activities and it worked perfectly but I'm trying to convert it to use ...
0
votes
0answers
22 views

Android Room read and write Data objects with dependencies

I have been trying to store an object into room database and retrieve it afterwards. The data that I need to store is the following JSON coming from a web service: { "id": "456797987", "...
2
votes
0answers
25 views

Android Room onConflict = OnConflictStrategy.IGNORE not working

I am using the room database in my android application. While inserting data into user I have added: // Not working onConflict = OnConflictStrategy.IGNORE/REPLACE @Insert(onConflict = ...
0
votes
1answer
32 views

Room Database distinct value

I am trying to integrate the room database in my android application. Now I want to query distinct result from DB but I am getting this error: error: The columns returned by the query does not have ...
1
vote
1answer
30 views

Data source always returns full data from room data base even if I provided the amount of data loaded each page

I am using paging (part of android Jetpack ) to retrieve data from my room DB. I wanted to fetch 50 records on each page. But 'DataSource.Factory.toLivedata(pageSize)' function returning full data ...
-1
votes
0answers
34 views

error: An abstract DAO method must be annotated with one and only one of the following annotations

When i'm trying to compile my Android project with Room, i have all this error. What can i do to have more informations about the issue or to fix this problem EDIT : I have to exact clue wich DAO's ...
2
votes
1answer
49 views

Get and observe three objects with Room/LiveData

I have following database relationship: In words: One Order has 0-n Books, one Order is assigned to one Customer. In my case, I have bookId. I want to launch some function when I get all associated ...
0
votes
0answers
8 views

Room database onCreate callback not called after destructive migration

I have some initial state that I need to create in my Room database. I do so in the onCreate callback: val database = Room.databaseBuilder(context, MyDatabase::class.java, "mydatabase").addCallback(...
0
votes
0answers
29 views

How to observe changes for sliding page in Room database?

What I mean, I want to create something like a sliding window/paginator with a fixed number of items for Room database. For example (look at the image below by link), I create any RecyclerView that ...
0
votes
1answer
16 views

Data isn't selected from Database with Room

I have the following code: private void onAddClick(){ String title = mTitleEdit.getText().toString(); String body = mBodyEdit.getText().toString(); Note note = new Note(); ...
0
votes
0answers
13 views

How to get all information from a table without using Live Data?

I want to get a List from Room database in Android without using LiveData. I tried this: How to get all data from room table in android using async Task in a List with some changes because I have a ...
0
votes
1answer
34 views

How to define the same conversion and select the right one with TypeConverter in Room

In my dao I have this method: @Query("SELECT category, group_concat(type) as types" + "FROM Type" + "GROUP BY category") public abstract LiveData<List<CategoryWithTypes&...
0
votes
1answer
49 views

Room database onConflict = OnConflictStrategy.REPLACE not working

I am working on Room database and trying to insert list of items(eg. list of Quotes which contains author name and a quote in my case). Following is the code I am using: // view model BaseApp....
0
votes
1answer
52 views

Android Room query not returning the LiveData

I am trying to return LiveData from Android Room. I am having trouble returning the result as LiveData. Here is the excerpt from Dao @Query("SELECT * FROM transaction_table") LiveData<List&...
0
votes
1answer
32 views

Not able to use same model for ROOM and Retrofit

I'm doing an api call, which response includes list of objects, the json response is: [ { "name": "jay", "age": 27, "avatar": "https://avatars.abc/bat_man/", "friends": [{ ...
0
votes
0answers
33 views

Room - Android. How to request data from multiple entities?

I have 4 different entities with the same type of data.. class { val Int val String val String } I am using ViewModel to request the data and right now I have for Observables which updates ...
0
votes
1answer
37 views

How to use Room Database in Android with Bazel?

I have lots of SQLite tables that has now become hard to manage at the app side because of multiple DAO classes. I am using Bazel as my build system but I can't figure out how to use Room DB with ...
0
votes
1answer
34 views

Android Room subquery in FROM clause not working as expected

I tested my query using https://sqliteonline.com/ but cannot get it to work with Android Room and I cannot understand why (believe me I've tried). Why is the query in my DAO not working? On the other ...
0
votes
2answers
16 views

ROOM Entity api field name starts with number

I have an API that returns an object that starts with a number, so I cannot parse it correctly with Room in Kotlin. @Entity(tableName ="1d") data class 1D( @SerializedName("percent") ...
0
votes
0answers
29 views

How can we use @DatabaseView in Android Room as DataSource for using it in PagedList.BoundaryCallback

In the recently Room version 2.1.0, Android team introduce DatabaseView: https://developer.android.com/training/data-storage/room/creating-views How can we select databaseview as DataSource.Factory ...
-1
votes
0answers
38 views

Manually creating a foreign key for Android room for a nested array

My json response is: { "categories": [ { "categoryName": "Events", "entityId": "QwN9goUaw6", ..... } ], "entityId": "T1nnwwpjOM" } My ...
0
votes
0answers
25 views

How to map NUMERIC SQLite type in Room?

I have a SQLite DB which I cannot change or migrate and need to map a NUMERIC column to my Kotlin class using Room. What do I need to use as a data type of the field in Kotlin class? When using ...
-1
votes
2answers
85 views

error: Cannot figure out how to save this field into database in my model class

I am developing a new application but I am getting the following error in my code: Cannot figure out how to save this field into database. You can consider adding a type converter for it. I ...
1
vote
1answer
24 views

i want to get last id in response of inserting in room persistence

am using room persistence library for my android application i want to get last id that is generated(primary key auto generated) when i am inserting in android room persistence library and then want ...
2
votes
1answer
41 views

Can't migrate a table to Room do to an error with the way booleans are saved in Sqlite

I've been trying to migrate my app to Room. I'm struggling with a particular table that can't be migrated directly because of the way it has been created. The fields were created with datatype BOOL ...
0
votes
0answers
31 views

How to return row count of data in room persistence

Am working on an assignment where I have to count for records in room database and if its zero(0), I show no data in textview otherwise the data is fetched in LiveData format. I found this method on ...
1
vote
1answer
17 views

Default Storage for room database

Whenever we extend a RoomDatabase to Create a Database Instance Where does it gets stored by default Local storage, External Storage, In Memory
0
votes
0answers
16 views

koin pass CoroutineScope as dependency for RoomDatabaseCallback

I have a database which requires a CoroutineScope for initialization. @Database(entities = [Word::class], version = 1) abstract class WordRoomDatabase : RoomDatabase() { abstract fun wordDao(): ...
0
votes
1answer
32 views

Compare two flowable streams in Rx

I have two tables. Table A and Table B. I am using Android with Room and Reactive Streams with ktx. The Table A has two columns Title, Ids. Row 1 - ['example', '1,2,3,4']. The Table B has two columns ...
-1
votes
1answer
22 views

error: Cannot figure out how to save this field into database

I need to type converter for calendar type to add room database. error: Cannot figure out how to save this field into database. You can consider adding a type converter for it.
-2
votes
1answer
60 views

how to convert Source type converter to room

I am developing a news app and implemented but I am not able to convert model class to typeconverter below my model class @Entity @ForeignKey(entity = Source.class,parentColumns ="source", ...
0
votes
1answer
37 views

How to query this in Android Room?

I try Room in my app,News.class contains related, such as science, economics... @Entity public class News { public List<String> related = new ArrayList<>(); } I want db can find News ...
0
votes
0answers
37 views

How to represent parent/child structures in recycler view?

I am struggling with how to present normalised data in a recycler. I'm trying to represent the structured lessons of a training course in the recycler, using different item types to represent the ...
0
votes
0answers
48 views

error: Cannot figure out how to save this field into database.?

I am developing android I have implemented room and getting multiple errors from build below errors You can consider adding a type converter for it. error: Cannot figure out how to save this field ...
0
votes
0answers
22 views

How to get more detail from remote server for each item got from database

I'm using RecyclerView + PagedListAdapter + Room to show the data in database. It works now. But I want to get more detail from remote server for each item got from database. How can I do?
1
vote
1answer
42 views

Android room custom update @Query with String array crash with “sqlite syntax ? error”

So I have a problem with UPDATE query inside @Query that tries to update a column that holds String[]. Converters: @TypeConverter public static String[] fromString(String value) { Type listType ...
0
votes
0answers
40 views

LiveData triggers only once when paging with room

ViewModel: val eventDataFactory = AppDatabase.getInstance(context)!!.eventDao().getEventList() val pagedListConfig = PagedList.Config.Builder() .setEnablePlaceholders(false) ...
0
votes
2answers
61 views

how to store basic D&D stats within my app using room, in such a way that they can be edited and retrieved

I am attempting to write an app for my D&D group, and one of the functions will be to store the groups character stats, which i will display in the app. I went to the following tutorials and ...
0
votes
1answer
44 views

Inheritance in the Room Persistence Library

TL;DR: How can I store and retrieve objects of type ClassA and ClassB which both inherit from ClassP in the same "list", using the Room Persistence Library? In other words, How should I store a ...
0
votes
0answers
35 views

Trying to pass LiveData List as an argument

I am trying to implement a SearchView in my room with a view SQLite Database. The app has a RecyclerView with a CardView that displays rows from the database. I am trying to make it so a user can use ...

http://mssss.yulina-kosm.ru