android-room

Kotlin Coroutines Flow with Room and state handling

半腔热情 提交于 2020-07-23 10:16:46
问题 I'm trying out the new coroutine's flow, my goal is to make a simple repository that can fetch data from a web api and save it to db, also return a flow from the db. I'm using room and firebase as the web api, now everything seems pretty straight forward until i try to pass errors coming from the api to the ui. Since i get a flow from the database which only contains the data and no state, what is the correct approach to give it a state (like loading, content, error) by combining it with the

Kotlin Coroutines Flow with Room and state handling

…衆ロ難τιáo~ 提交于 2020-07-23 10:16:09
问题 I'm trying out the new coroutine's flow, my goal is to make a simple repository that can fetch data from a web api and save it to db, also return a flow from the db. I'm using room and firebase as the web api, now everything seems pretty straight forward until i try to pass errors coming from the api to the ui. Since i get a flow from the database which only contains the data and no state, what is the correct approach to give it a state (like loading, content, error) by combining it with the

Recycler view shows all data from Room database instead of just showing data of selected ids

我们两清 提交于 2020-07-23 08:14:53
问题 The RecyclerView when launched shows all the data instead of showing data of a specific id. I am using Room database and as I understand the problem is when the ViewModel is getting initialized, the repository gets all the colors.. I couldn't figure out how to code in Repository, so that when the ViewModel is initialized it only gets data of specific ids instead of all data. In one of the answers in stack it mentions something about using "SwitchMap"...but I am new to Android so not sure if

Recycler view shows all data from Room database instead of just showing data of selected ids

二次信任 提交于 2020-07-23 08:13:16
问题 The RecyclerView when launched shows all the data instead of showing data of a specific id. I am using Room database and as I understand the problem is when the ViewModel is getting initialized, the repository gets all the colors.. I couldn't figure out how to code in Repository, so that when the ViewModel is initialized it only gets data of specific ids instead of all data. In one of the answers in stack it mentions something about using "SwitchMap"...but I am new to Android so not sure if

Recycler view shows all data from Room database instead of just showing data of selected ids

ぃ、小莉子 提交于 2020-07-23 08:12:15
问题 The RecyclerView when launched shows all the data instead of showing data of a specific id. I am using Room database and as I understand the problem is when the ViewModel is getting initialized, the repository gets all the colors.. I couldn't figure out how to code in Repository, so that when the ViewModel is initialized it only gets data of specific ids instead of all data. In one of the answers in stack it mentions something about using "SwitchMap"...but I am new to Android so not sure if

Android Paging library sqlite data storage concern

◇◆丶佛笑我妖孽 提交于 2020-07-19 11:13:17
问题 Over the past days I have been getting comfortable with Android Architecture Components and I've been mostly interested in the Paging Library for handling and displaying lists of data from a remote source. For the best UX it is better to load data first into the database, in this case Room then display it in a recyclerview using the pagingLibrary and adapters. My concern is this, lets say an api has 1000s of records or a twitter feed even and all this data has to pass through the db then to

Android Paging library sqlite data storage concern

送分小仙女□ 提交于 2020-07-19 11:12:58
问题 Over the past days I have been getting comfortable with Android Architecture Components and I've been mostly interested in the Paging Library for handling and displaying lists of data from a remote source. For the best UX it is better to load data first into the database, in this case Room then display it in a recyclerview using the pagingLibrary and adapters. My concern is this, lets say an api has 1000s of records or a twitter feed even and all this data has to pass through the db then to

is there any way to run nested query in room database

让人想犯罪 __ 提交于 2020-07-18 07:45:14
问题 I am migrating my old Android project to new standards, I got stuck in between room database , not able to find how to execute these 2 SQLite commands using room database . I have 2 queries which are working in a nested manner, so to achieve the same result using room is there any possibility. default public ArrayList getOfflineRoomsAndObjectsByParentIds(String parentId, String site_id, Context context) { databaseHandler = new DatabaseHandler(context); Cursor cr = null; ArrayList<Room>

Android Room - Handling List of Objects in an Object and querying result

久未见 提交于 2020-07-17 12:07:22
问题 Im working with Android's Room Database and am having some big problems understanding how to: When I add a Person to the database, it adds all its variables e.g. List<Shoe> , List<Pet> etc. to the database as well. Create relations such that when I retrieve a Person , all its fields are retrieved e.g Pet, Shoe, Shirt etc. (Not sure what type of query that is) Perform simple query e.g. Retrieve Person where shoe.name = "boot" ; I know you must use Foreign Key relationships with list of objects

Android Room - Handling List of Objects in an Object and querying result

佐手、 提交于 2020-07-17 12:05:07
问题 Im working with Android's Room Database and am having some big problems understanding how to: When I add a Person to the database, it adds all its variables e.g. List<Shoe> , List<Pet> etc. to the database as well. Create relations such that when I retrieve a Person , all its fields are retrieved e.g Pet, Shoe, Shirt etc. (Not sure what type of query that is) Perform simple query e.g. Retrieve Person where shoe.name = "boot" ; I know you must use Foreign Key relationships with list of objects