Questions tagged [android-room]

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

0
votes
0answers
6 views

Android room update conflict replace but ignore a specific column

Android Room has this conflict strategy REPLACE but I manage a column this is maintained locally in the entity and not present in the server payload. Is there a way to tell DONOT replace entire row ...
0
votes
0answers
16 views

Databinding with Koin and Room

I have the following issue: I am using Koin for DI and Room for persistence. Now my room dependencies are the following: // Architecture Component - Room implementation "android.arch.persistence.room:...
0
votes
0answers
41 views

Room persistence library (dependency issue), MVVM design pattern

Iam following MVVM tutorial and when adding Room dependency 1- I got this this error in compile: Note: Failed to read get kotlin metadata for [Ljava.lang.Object;@54d771f9 Note: Failed to read get ...
0
votes
1answer
24 views

Room not finding setter method for an entity

Room is not finding setType method defined in the parent class. Gives cannot find setter for field error during compilation. Parent class public class Data { private int type = -1; public ...
0
votes
0answers
16 views

How to handle UNIQUE constraint failed by making a Toast pop with the specific error

i tried to think of a way to handle the UNIQUE constraint faild error by making a Toast pop that says something like: "alreay have a user" or something of that sort. I know you can use 'onConflict' ...
0
votes
0answers
8 views

Restoring Room database with same method, but with different DAO’s, it’s making me crazy

Have 5 room database with different entities and Dao’s each. I use the same methods for backup and restore using the code bellow. All of them work perfectly except for one that throws me the following ...
0
votes
0answers
21 views

Can I store a (Hash)Map in my Room Entity?

So I was searching for an answer but I didn't really found anything fitting for me. What I want to do: I am having my Entity called "Sub". It already has all kind of values, etc. But now I need some ...
0
votes
0answers
13 views

Android Room Entity Not Updating

I have a logged in user, (Coach) and in profile I want to display some more fields from that entity such as program count, etc from a network call which will be saved to Coach entity table, while ...
1
vote
0answers
14 views

paging library not showing anything in recyclerview

i'm trying to load bunch of list from room database, with paging library, but somehow that i don't really understand, the list never shown up i add a repository class between dao and viewmodel, not ...
0
votes
0answers
30 views

Get column from another entity using foreign keys in Room

I have two different entities. One has two references to the other one and I need to get a attribute of the reference. my_main_table.primary_type is a foreign key of types._id and my_main_table....
0
votes
0answers
22 views

Room Find Entity By Id, Update and Return Values

I have fetched and cached a list of programs using retrofit, room and Model-view-view-model pattern. The items are displayed in a list, when each item is clicked, I show a dialog fragment which ...
1
vote
0answers
19 views

How to access/use Room DB (Android, Kotlin, MVVM) in background IntentService?

I'am building a chat app with Smack on Android. The ChatManager and other Listeners are running in an IntentService (right now). When I receive a message I want to store it in my room DB. From this ...
0
votes
0answers
27 views

Handling an exception within Room

I migrated from ormlite to Android Room I use custom query which can fail, but I don't find how to handle the exception try { appDatabase.query(new SimpleSQLiteQuery(sql)); } catch (SQLException e)...
-2
votes
1answer
27 views

Limiting Room inserts

I have to limit Android Room table rows count to 10. When 11-th element is coming I need to remove first element and insert last. How to implement this functionality. Thanks
0
votes
1answer
29 views

FOREIGN KEY constraint failed (code 787) in Room database

I'm trying to learn relations in the Room database, but I have some problem. I want to put Expense to Date, but app crashes and logcat shows this: Caused by: android.database.sqlite....
0
votes
0answers
19 views

Android Room: storing an object hierarchy and querying for the superclass

In my application there is a User superclass and Coach and Player classes that extend User. I'd like to be able to use DAO methods like these: @Query fun getUsers(): Flowable<List<User>> ...
2
votes
3answers
46 views

Room DAO Order By ASC or DESC variable

I'm trying to make a @Query function in my @Dao interface which has a boolean parameter, isAsc to determine the order: @Query("SELECT * FROM Persons ORDER BY first_name (:isAsc ? ASC : DESC)") List&...
0
votes
0answers
14 views

Android Room library , how to load a pre-populated SQLite binary?

I have SQLite database, small in size (~4 Mb), but containing ~50.000 rows. The db is only to be queried, no data manipulation. The Room persistence library is used to manage the data retrieval What ...
0
votes
0answers
8 views

Android RecyclerView Layout Spacing Issue

I'm trying to create a recyclerview layout that populates from a Room database where each entry consists of an imageview and a textview. There's some strange spacing above and below the imageview. Any ...
0
votes
0answers
23 views

Why I am getting an exception while inserting in database using Room library? [duplicate]

I've created local database using Room library to enter the User information in the users table in my android application. Inside activity class, I've called the UserDao's addUser method to insert the ...
0
votes
1answer
20 views

Room SQLite - How to make a SELECT returning 1 object?

I've found a lot of Room tutorials, but none of them explains this. How can I run a query returning one object, not a LiveData? I have this method in my Room Dao: @Dao public interface TrainingDao {...
0
votes
3answers
75 views

Alternative to multiple constructors

I have this constructor... public ShiftLog(String companyName, boolean workedForAgent, String agentName, Date shiftStart, Date shiftEnd, boolean breakTaken, ...
-2
votes
1answer
34 views

How structure a SQLite database for offline support?

I'm trying to give the offline support in my app, so user can read the information without the internet also. I'm creating an app to show some packages from different companies. I have created my API ...
0
votes
0answers
16 views

Volley to Room SQLite with existing Primary keys

I have a REST API, which is providing the JSON as follows { "id":3, "package":"premimum", "company_id":6 } Now I want to fetch the data from the the API and then add that data to the ...
2
votes
0answers
43 views

Room Database functions WEEK(), MONTH(), etc

I have a room database with a table "Entries" where I have the columns value(int), cat_id(int) and date(Date). I want to get the sum of all entries of the current month and all entries of the ...
0
votes
0answers
7 views

In Android with Room, can I have tables with several PK columns to make JOIN with other tables?

I'd like to make a JOIN between two or more tables with Room. I have found simple examples, but my tables have several columns PK. How can I do it? Or do I have to create an unique PK for each table?
0
votes
0answers
23 views

Android room database - Not sure how to convert a Cursor to this method's return type

I'm trying to save this object in Room database, I read about Typeconverters for converting complex objects in one filed that can be stored in database. I am getting this error: error: Not sure ...
0
votes
0answers
20 views

RxJava2 doOnNext returns later than intended

So I'm pretty sure that I'm kind of at a loss here. The expected behavior is: Get data from API -> save it in the local DB -> load data from the local DB and display it First of all in my ...
0
votes
2answers
11 views

Use SingleDateAndTimePicker in Room database

I have this code for the room database... ShiftLog.java @Entity public class ShiftLog { @PrimaryKey @ColumnInfo(name ="user_uid") private int userUid; @ColumnInfo(name ="...
0
votes
0answers
31 views

How to use calculated field in Room Dao to order records

I have an entity as below: @Entity(tableName = "PupilScore", primaryKeys = ["SubjectId", "PupilId"], indices = arrayOf(Index(value = ["SubjectId", "PupilId"], unique = true, name ="...
1
vote
1answer
30 views

Android Room, wrong column name & column is not nullable

I´m using Room instead of classic sqlite statements now, and I´m having the following problems. When I open my "tags" Table, I´m getting the following error. java.lang.IllegalStateException: ...
2
votes
1answer
50 views

Room Insert List of POJO and Retrieve in Recyclerview

I am using room as data store for my app. I am trying to save a list of sessions from a successful network call in viewmodel class. I have used a repository for interacting with the dao and asynctask ...
0
votes
0answers
10 views

Room SQL and Subtract

I have two tables in the Room database. I know how to get sum from both of them, but how to subtract one from the other? This is my SQL query for sum of one table: @Query("SELECT COALESCE(sum(...
1
vote
2answers
29 views

@RawQuery with ViewModel

I followed this Room With a View tutorial and everything works as expected. Now I'm trying to implement @RawQuery and display LiveData with ViewModel. I want to display a list of items that have a ...
1
vote
2answers
32 views

Android Room Composit Primary key issue

The strange issue below is code sample, not able to create the composite primary key @Entity(tableName = JobEdnsubLvlEntity.TABLE_NAME,primaryKeys = {"ednid","ednsubid"}) public class ...
-1
votes
0answers
20 views

Is there a way to connect Room database with MySql workbench?

I am working on an android project and we have a server side database on MySql workbench and are using Room for our local database in Android Studio. Is there a way to connect/sync the two? Thank you....
0
votes
0answers
19 views

Android Room Complex Queries

All the examples I've seen show a simple selection "SELECT * from user". But we all know in the real world we will have queries like this: SELECT COUNT(1) QTD_MY_PENDING_SO FROM ( SELECT IFNULL((...
0
votes
2answers
38 views

Android Room persistance library. Drop Table

I need to know how to "DROP FROM Table" using Room Persistence Library. I already know that we can delete all the rows using the method: @Query("DELETE FROM table") void deleteAll(); However, what ...
0
votes
0answers
39 views

android room/livedata - how to have a sql value increment an int column count and possibly limit it's value

For example let's say I have a row with two columns (TEXT apple) and (INTEGER apple_count), using Room and LiveData how can I increase the value of apple_count by one every time a button is pressed ...
2
votes
1answer
34 views

Completable delete functions from DAO implementation produces IllegalStateException

Assume that we have simple DAO interface: @Dao interface MyDao { @Delete fun delete(entity: MyEntity): Completable } and we're expecting from Room that it will generate function which ...
0
votes
1answer
49 views

Why do Room Tables have duplicate id columns? [duplicate]

I am investigating the use of Room in my current Android project. When using com.facebook.stetho:stetho:1.5.1 to check my Sqlite Tables structure and content I have discovered all my tables display ...
0
votes
1answer
24 views

Infinite loop of SyncAdapter

Yesterday I tested my app in some Virtual devices in Genymotion, and I realized some times, App sends infinite sync requests to the server on some devices (all of them were API<21). What's the ...
0
votes
1answer
47 views

How to use nested models in room persistence library?

how to relate user table "addressId" column with address table "id" column? and when i insert user model data then how can i insert data in both tables "user and address". and same case in fetching ...
0
votes
0answers
46 views

Databinding + Room in Kotlin. How to bind data class in Kotlin?

I have make one demo of Room database which is purely in kotlin and its successfully run. But now I convert that demo into databinding also. Problem is that in kotlin we make data class as entity ...
0
votes
1answer
35 views

Android Room error: The columns returned by the query does not have the fields even though they are annotated as non-null or primitive

So i wanna join my table using Room in Android Studio and this is my model class. Ibadah.java @Entity(tableName ="tibadah") public class Ibadah implements Serializable { @PrimaryKey(...
-1
votes
1answer
30 views

How can I make the thread wait between 2 methods

I have this function- inserting data to Room database in android app: public void insertInfoToDB() { final Thread thread = new Thread(new Runnable() { @Override public void run() { ...
1
vote
1answer
23 views

TypeConverters not working for Collections in @Query

I've an entity called Events which is defined as follows: @Entity(tableName ="Events") data class Event(@PrimaryKey val id: Long, val name: String, val venues: Set<String>, val rating: Int) I'...
0
votes
0answers
16 views

Check database integrity in Android Room

Is there a way to check my app Sqlite database integrity via Room?
0
votes
0answers
17 views

How to fetch single value from an entity Room Database?

My application contains Room Database which has two tables,named as: ParamHead and ParamValue. ParamHead consists of two columns head_id and head_name, where head_id is primary key. ParamValue ...
4
votes
5answers
537 views

Note: Failed to read get kotlin metadata for [Ljava.lang.Object;@79d6c4df

I keep getting this error. I am working on a project and in the middle of development, I decided to migrate to Android X. I get the error below: Note: Failed to read get kotlin metadata for [Ljava....

http://mssss.yulina-kosm.ru