Closed lpellegr closed 8 years ago
I think the best answer to your question is that the constructor to SquidCursor is public, so you can build a SquidCursor yourself if you have all the necessary information. The three things you need are:
ICursor
. This can be constructed by calling new SquidCursorWrapper(cursor)
on your ContentProvider cursor result.When put together, it might look something like this:
Cursor contentProviderResult = ...;
SquidCursor<MyModel> squidCursorResult = new SquidCursor(
new SquidCursorWrapper(contentProviderResult),
MyContract.MODEL_CLASS, MyContract.MODEL_PROPERTIES);
Then you can use the SquidCursor as usual.
Hope that helps!
@sbosley Thank you a lot for the explanations. My usecase is working.
I have created a content provider for my app A by using Squidb 3.1.0. It follows the great explanations from the Wiki. The overriden query method from my content provider returns a Cursor to comply with the Android interface. It is done by casting the concrete object instance as follows:
Then, from another app B (which embeds the same data model as the one exposing the content provider), I would like to query the content provider of app A and iterate over the result using a SquidCursor. There is no problem to retrieve the result from the content provider:
but to do something like the following, it seems that cursor needs to be of type SquidCursor:
Unfortunately, the resulting cursor object cannot be casted to SquidCursor. Its type seems to be android.content.ContentResolver$CursorWrapperInner.
Is there a mean to achieve what I am trying to do? otherwise, what is the recommended way to handle content provider query result?