android-room

Android Kotlin Room Repository unable to retrieve row from within detail activity

梦想的初衷 提交于 2021-02-20 01:00:08
问题 I'm really struggling with this & would appreciate some help please. I'm learning Android Kotlin & building an app that displays a list of walking routes (downloaded from the cloud) in a RecyclerView &, when a route is selected I want to display all details of the route - a simple Master-Detail app. Since, I'm learning I also want to try and use best practice. I have most of it working fine using a Room database & a Repository. The database is correctly populated and the RecyclerView displays

How to properly approach threading with Room

泄露秘密 提交于 2021-02-19 02:39:59
问题 I am confused about Room and can not find an answer in the documentation. So, the library enforces using queries on a separate Thread, which is understandable. However, it seems that Delete queries are not included in this limitation and can be freely called from the UI Thread. They also always return a raw output value, without a chance to wrap it in an Observable. What is the correct way to use the delete call in Room then ? Should it be run on a separate Thread? If not, what about

Room how can I convert a custom made object

a 夏天 提交于 2021-02-18 22:55:12
问题 I'm new to Room, and I'm not understanding how I should go about this. I have an Entity Movie and another Entity called ÙpcomingMovies . @Entity public class Movie { @PrimaryKey @NonNull public String id; @ColumnInfo public String name; @ColumnInfo public String title; } @Entity public class UpcomingMovies { @PrimaryKey(autoGenerate = true) public int id; @ColumnInfo public Movie movie; } So I already know Room has a problem with converting Objects, but I still havent seen how to convert a

How to implement a Room LiveData filter

那年仲夏 提交于 2021-02-18 19:34:22
问题 I do not know how to implement a filter query properly inside the Repository and the ViewModel to use it to display the filtered string in a Textview or anything else really. My Entity, Dao, Repository, and ViewModel are as follows: User.kt @Entity(tableName = "user_data") data class User ( @PrimaryKey(autoGenerate = true) val id: Int, @ColumnInfo(name = "name") val name: String ) UserDao.kt @Dao interface UserDao { @Insert fun addUser(user: User) @Query("SELECT name FROM user_data WHERE name

Listening socket.io events and updating LiveData (a class of android.arch.lifecycle)in application class android

主宰稳场 提交于 2021-02-18 19:10:28
问题 I am working on a chat application and Currently I am listening and emitting socket events in an Activity. Now i want to listen all the socket events even when chat activity is not in foreground as i want to store all the messages from different users in the local DB at the same time i want to update LiveData to update UI. In order to achieve this I am listening socket events in the Application class as following: public class ChatApplication extends Application { public Socket mSocket;

Listening socket.io events and updating LiveData (a class of android.arch.lifecycle)in application class android

只谈情不闲聊 提交于 2021-02-18 19:09:57
问题 I am working on a chat application and Currently I am listening and emitting socket events in an Activity. Now i want to listen all the socket events even when chat activity is not in foreground as i want to store all the messages from different users in the local DB at the same time i want to update LiveData to update UI. In order to achieve this I am listening socket events in the Application class as following: public class ChatApplication extends Application { public Socket mSocket;

Listening socket.io events and updating LiveData (a class of android.arch.lifecycle)in application class android

早过忘川 提交于 2021-02-18 19:08:53
问题 I am working on a chat application and Currently I am listening and emitting socket events in an Activity. Now i want to listen all the socket events even when chat activity is not in foreground as i want to store all the messages from different users in the local DB at the same time i want to update LiveData to update UI. In order to achieve this I am listening socket events in the Application class as following: public class ChatApplication extends Application { public Socket mSocket;

Android room - How to clear sqlite_sequence for all table

岁酱吖の 提交于 2021-02-18 15:29:27
问题 If user logout from the app, i'm clearing data from tables one by one using @Query("DELETE FROM tableName") Then i'm trying to clear the sqlite_sequence for all table one by one using below code. database = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, DatabaseMeta.DB_NAME) .build(); database.query("DELETE FROM sqlite_sequence WHERE name = ?", new Object[]{"tableName"}) Unfortunately clearing sqlite_sequence is not working. So if the user login again, then the starting

How to save nested List<String> in RoomDB on Android

我们两清 提交于 2021-02-18 11:47:06
问题 Hey google have an example on using @Relation @Entity public class Pet { int userId; String name; // other fields } public class UserNameAndAllPets { public int id; public String name; @Relation(parentColumn = "id", entityColumn = "userId") public List<Pet> pets; } Is it possible to save list of String without creating extra class for it. I want to avoid incosistence between my JsonProperty and a room Entity W would like to have soemthing like that public class UserNameAndAllPets {

Room: could I check passing value to query for NULL?

﹥>﹥吖頭↗ 提交于 2021-02-18 11:38:30
问题 I'm using Room libs, have DB Stations and want to execute query to get Stations with/without filter. UPD. I have DAO and I want to get all the records when my array (groupIds) is null or empty and get filtered list if I have at list one element in array. @Query("SELECT * FROM $STATIONS_TABLE_NAME WHERE ((:groupIds) IS NULL OR $GROUP_ID IN(:groupIds)) fun getStationsWithFilter(groupIds: IntArray?): Flowable<List<DbStation>> At this moment I had an issue 08-29 16:09:00.139 9508-9508/-