{"action":"closed","issue":{"url":"https://api.github.com/repos/yahoo/squidb/issues/200","repository_url":"https://api.github.com/repos/yahoo/squidb","labels_url":"https://api.github.com/repos/yahoo/squidb/issues/200/labels{/name}","comments_url":"https://api.github.com/repos/yahoo/squidb/issues/200/comments","events_url":"https://api.github.com/repos/yahoo/squidb/issues/200/events","html_url":"https://github.com/yahoo/squidb/issues/200","id":168107115,"number":200,"title":"Consuming content provider query result using Squidb","user":{"login":"lpellegr","id":128898,"avatar_url":"https://avatars.githubusercontent.com/u/128898?v=3","gravatar_id":"","url":"https://api.github.com/users/lpellegr","html_url":"https://github.com/lpellegr","followers_url":"https://api.github.com/users/lpellegr/followers","following_url":"https://api.github.com/users/lpellegr/following{/other_user}","gists_url":"https://api.github.com/users/lpellegr/gists{/gist_id}","starred_url":"https://api.github.com/users/lpellegr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpellegr/subscriptions","organizations_url":"https://api.github.com/users/lpellegr/orgs","repos_url":"https://api.github.com/users/lpellegr/repos","events_url":"https://api.github.com/users/lpellegr/events{/privacy}","received_events_url":"https://api.github.com/users/lpellegr/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-28T14:18:36Z","updated_at":"2016-07-28T20:20:57Z","closed_at":"2016-07-28T20:20:57Z","body":"I have created a content provider for my app _A_ by using Squidb _3.1.0_. It follows [the great explanations from the Wiki](https://github.com/yahoo/squidb/wiki/Implementing-a-ContentProvider).  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:\r\n\r\n```\r\npublic Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {\r\n        Query query;\r\n        switch (URI_MATCHER.match(uri)) {\r\n            case XXX:\r\n                query = buildXXXQuery(); // make use of PROJECTION_MAP\r\n                break;\r\n            default:\r\n                throw new UnsupportedOperationException(\"Unsupported URI: \" + uri);\r\n        }\r\n\r\n        query.limit(getLimit(uri));\r\n        SquidCursor<AbstractModel> cursor = mDatabase.query(AbstractModel.class, query);\r\n        return (Cursor) cursor.getCursor();\r\n}\r\n```\r\n\r\nThen, 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:\r\n\r\n```\r\nCursorLoader cursorLoader = \r\n    new CursorLoader(getApplicationContext(), contentUri, null, null, null, null);\r\n\r\nCursor cursor = cursorLoader.loadInBackground();\r\n```\r\n\r\nbut to do something like the following, it seems that _cursor_ needs to be of type _SquidCursor_:\r\n\r\n ```\r\nAndroidTableModel tableModel = new XXX();\r\nwhile (cursor.moveToNext()) {\r\n    tableModel.readPropertiesFromCursor(cursor.);\r\n    Timber.d(\"DB entry %d loaded\", tableModel.getRowId());\r\n}\r\n```\r\nUnfortunately, the resulting _cursor_ object cannot be casted to _SquidCursor_. Its type seems to be _android.content.ContentResolver$CursorWrapperInner_.\r\n\r\nIs there a mean to achieve what I am trying to do? otherwise, what is the recommended way to handle content provider query result? \r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"lpellegr"}}