-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to access content providers using Room? #13
Comments
Unfortunately no. Room is designed to work with SQLite database. |
Room is not meant for it, but I was wondering the same thing regarding the Live Data. Could you give examples how to load MediaStore/ContactsProvider with live data, instead of Loaders? I'll be implementing this soon, and I'd like to use LiveData instead of Loaders, and of course it's also important that my LiveData gets notified of any change in the MediaStore, which somehow already works with the Loader.. @yigit Thanks! |
One more thing is SyncAdapter. Of course we can update Room database directly from it and all associated LiveData objects should get the update. But what about the ContentProvider instances connected to the same SQLite db? What to do with ContentProviderClient, which is passed into a SyncAdapter instance? |
I'm in the same boat @Lingviston is. I'm migrating to Room, but without a content provider, the sync engine won't run. |
@bpappin it is generally OK, because Room is not a replacement for ContentProviders. But since Room can be used by ContentProvider I think it should come with helper classes which allow avoid writing lots of boilerplate code when you need to communicate with Room DB in your own app through the CP protocol. |
@gajicm93 Did you manage to implement using live data to load MediaStore/ContactsProvider? |
@KryptKode I think I didn't end up trying it, but if you need it, I would recommend to start by looking into Room generated code to see how they convert SQL queries into LiveData, and write the same code manually for MediaStore. If you need any additional help just send me a message. |
So Room cannot be used with content providers like call logs,contacts etc? |
Yes @vyadav33e |
I have two Application, Application A is main App and Application B is child Application i have database in Application A(main app) now i want to use Application A database into Application B and use all data in Application B i found some answers but all answers are SQLite with ContentProvider but not for Room and no any example found. |
One of the most common content provider that is accessed is Android's MediaStore. How do I access data of Android MediaStore using Room?
The text was updated successfully, but these errors were encountered: