android-room

items in RecyclerView disappeared OnPause of Activity

我的未来我决定 提交于 2020-06-01 06:41:46
问题 my app add item to Recyclerview at 12 AM it added then it disappears when OnPause of activity here is my code & i don't know if it deleted from my RoomDatabase or from my RecyclerView ListOfItemsActivity.java RecyclerView notesRecyclerView; NotesRecyclerViewAdapter notesRecyclerViewAdapter; RecyclerView.LayoutManager layoutManager; NotesViewModel notesViewModel; List<Note> note = new ArrayList<>(); private static final String PREF_PAUSE_TIME_KEY = "exit_time"; private static final Long MILLIS

items in RecyclerView disappeared OnPause of Activity

一曲冷凌霜 提交于 2020-06-01 06:41:06
问题 my app add item to Recyclerview at 12 AM it added then it disappears when OnPause of activity here is my code & i don't know if it deleted from my RoomDatabase or from my RecyclerView ListOfItemsActivity.java RecyclerView notesRecyclerView; NotesRecyclerViewAdapter notesRecyclerViewAdapter; RecyclerView.LayoutManager layoutManager; NotesViewModel notesViewModel; List<Note> note = new ArrayList<>(); private static final String PREF_PAUSE_TIME_KEY = "exit_time"; private static final Long MILLIS

Room LiveData fires twice with one stale emission

蹲街弑〆低调 提交于 2020-05-29 10:28:49
问题 This issue was originally observed in a project with MVVM architecture (single activity / multiple fragments) when performing an insert/delete operation to the database and then navigating back to the home fragment. The home fragment then resubscribes to the LiveData in the home ViewModel and LiveData emits twice: One incorrect stale event corresponding to before the database operation A second correct event corresponding to after the database operation I have created a very simple example

How to use parameter fields in Room @Query?

╄→尐↘猪︶ㄣ 提交于 2020-05-28 13:33:07
问题 I have a User class with a field id , so I wanted to run the following query with Room: @Query("SELECT * FROM ticket where user_id = :user.id") LiveData<Ticket> loadFromUser(User user); But I am getting error marks on Android Studio on user.id and all examples I find online only use the direct parameter of the @Query method, usually a String or an int . Is it possible to use an object's field in a Room @Query ? If positive, so what's the proper way of referencing it. 回答1: You can't pass

How to use parameter fields in Room @Query?

人盡茶涼 提交于 2020-05-28 13:32:53
问题 I have a User class with a field id , so I wanted to run the following query with Room: @Query("SELECT * FROM ticket where user_id = :user.id") LiveData<Ticket> loadFromUser(User user); But I am getting error marks on Android Studio on user.id and all examples I find online only use the direct parameter of the @Query method, usually a String or an int . Is it possible to use an object's field in a Room @Query ? If positive, so what's the proper way of referencing it. 回答1: You can't pass

how to change LiveData observable query parameter with room database in android?

给你一囗甜甜゛ 提交于 2020-05-27 05:41:28
问题 I am using live data with room database and my activity observes live data provided from room database. @Query("SELECT * FROM BUS WHERE BUS_CATEGORY = :busCategory") LiveData<List<Bus>> getLiveBuses( String busCategory); ViewModels gets LiveData via Dao(Data Access Object) and activity observes this live data. Now it works fine. But when busCategory changes i can't modify this live data to get buses for newly selected busCategory. So how can i observe this same liveData where query parameters

Room - Delete executes after I insert new values

偶尔善良 提交于 2020-05-25 07:17:46
问题 I'm studying Rxjava2 and I'm trying to integrate the Room Library with Rxjava2. The problem is: I have a populated table and every time I login in the app, I need to delete this table and then insert a new content in database. Separately, the delete and insert works fine, but when I try to insert new values after I delete the table content, the delete method deletes all the new values.. (some parts of the code is in kotlin and others in java) I already tried this: RxJava2 + Room: data is not

Room - Delete executes after I insert new values

僤鯓⒐⒋嵵緔 提交于 2020-05-25 07:17:14
问题 I'm studying Rxjava2 and I'm trying to integrate the Room Library with Rxjava2. The problem is: I have a populated table and every time I login in the app, I need to delete this table and then insert a new content in database. Separately, the delete and insert works fine, but when I try to insert new values after I delete the table content, the delete method deletes all the new values.. (some parts of the code is in kotlin and others in java) I already tried this: RxJava2 + Room: data is not

Room - Delete executes after I insert new values

让人想犯罪 __ 提交于 2020-05-25 07:17:08
问题 I'm studying Rxjava2 and I'm trying to integrate the Room Library with Rxjava2. The problem is: I have a populated table and every time I login in the app, I need to delete this table and then insert a new content in database. Separately, the delete and insert works fine, but when I try to insert new values after I delete the table content, the delete method deletes all the new values.. (some parts of the code is in kotlin and others in java) I already tried this: RxJava2 + Room: data is not

Room TypeConverter

南笙酒味 提交于 2020-05-23 10:39:08
问题 I am not sure what is the fuss about Room as I find it very crappy. Almost nothing works as expected. To my issue I want to test the type converter thingy they have (so far disappointed). To test it I made a simple class from an example I saw online. I am sure it is something stupid not even related to the code but I will give it a try here anyway. So far I have: @Entity public class User { @PrimaryKey private int id; private String name; @TypeConverters(Converters.class) List<String> pets =