{"action":"created","issue":{"url":"https://api.github.com/repos/square/sqlbrite/issues/23","labels_url":"https://api.github.com/repos/square/sqlbrite/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/square/sqlbrite/issues/23/comments","events_url":"https://api.github.com/repos/square/sqlbrite/issues/23/events","html_url":"https://github.com/square/sqlbrite/issues/23","id":70379035,"number":23,"title":"Android SQLBrite not getting latest inserted msg","user":{"login":"rafaelekol","id":1390965,"avatar_url":"https://avatars.githubusercontent.com/u/1390965?v=3","gravatar_id":"","url":"https://api.github.com/users/rafaelekol","html_url":"https://github.com/rafaelekol","followers_url":"https://api.github.com/users/rafaelekol/followers","following_url":"https://api.github.com/users/rafaelekol/following{/other_user}","gists_url":"https://api.github.com/users/rafaelekol/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelekol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelekol/subscriptions","organizations_url":"https://api.github.com/users/rafaelekol/orgs","repos_url":"https://api.github.com/users/rafaelekol/repos","events_url":"https://api.github.com/users/rafaelekol/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelekol/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-23T10:54:29Z","updated_at":"2015-04-24T01:28:31Z","closed_at":"2015-04-24T01:28:31Z","body":"I posted my issue to StackOverflow http://stackoverflow.com/questions/29820730/android-sqlbrite-not-getting-latest-inserted-msg\r\n\r\nI use SQLBrite subscriber for database changes. This is my Observable and subscriber:\r\n```java\r\nString NEW_MSG_QUERY = \"SELECT * FROM \"\r\n                + GrouviDatabaseContract.MessageEntry.TABLE_NAME\r\n                + \" WHERE \"\r\n                + GrouviDatabaseContract.MessageEntry.COLUMN_NAME_GROUP_ID\r\n                + \" LIKE ? AND \"\r\n                + GrouviDatabaseContract.MessageEntry.COLUMN_NAME_MESSAGE_ID\r\n                + \" >= ? ORDER BY \"\r\n                + GrouviDatabaseContract.MessageEntry.COLUMN_NAME_CREATED_AT\r\n                + \" DESC\";\r\nString grpId = String.valueOf(groupId);\r\nString msgId = String.valueOf(dividerMsgId);\r\nObservable<Query> freshMessages = sqlBrite.createQuery(GrouviDatabaseContract.MessageEntry.TABLE_NAME, NEW_MSG_QUERY, grpId, msgId);\r\nfreshMessages.subscribe(new Action1<Query>() {\r\n    @Override\r\n    public void call(Query query) {\r\n        Log.d(TAG, \"cursor worked\");\r\n        parseQueryData(query);\r\n    }\r\n});\r\n```\r\n\r\nMy insert code:\r\n```java\r\nContentValues values = new ContentValues();\r\nvalues.put(GrouviDatabaseContract.MessageEntry.COLUMN_NAME_MESSAGE_ID, message.getId());\r\n........\r\nvalues.put(GrouviDatabaseContract.MessageEntry.COLUMN_NAME_USER_NAME, message.getUserName());\r\nvalues.put(GrouviDatabaseContract.MessageEntry.COLUMN_NAME_IS_BLOCKED, isBlocked);\r\nsqlBrite.insert(GrouviDatabaseContract.MessageEntry.TABLE_NAME, values);\r\n```\r\nI successfully insert new items via SQLBrite wrapped SQLiteHelper. Problem is that I am not getting the latest inserted message. I got all messages, but the latest inserted. By logs, everything seems correct. Message is inserted, and then Subscriber is triggered.\r\n\r\nAm I doing everything right?"},"comment":{"url":"https://api.github.com/repos/square/sqlbrite/issues/comments/95767894","html_url":"https://github.com/square/sqlbrite/issues/23#issuecomment-95767894","issue_url":"https://api.github.com/repos/square/sqlbrite/issues/23","id":95767894,"user":{"login":"JakeWharton","id":66577,"avatar_url":"https://avatars.githubusercontent.com/u/66577?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeWharton","html_url":"https://github.com/JakeWharton","followers_url":"https://api.github.com/users/JakeWharton/followers","following_url":"https://api.github.com/users/JakeWharton/following{/other_user}","gists_url":"https://api.github.com/users/JakeWharton/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeWharton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeWharton/subscriptions","organizations_url":"https://api.github.com/users/JakeWharton/orgs","repos_url":"https://api.github.com/users/JakeWharton/repos","events_url":"https://api.github.com/users/JakeWharton/events{/privacy}","received_events_url":"https://api.github.com/users/JakeWharton/received_events","type":"User","site_admin":false},"created_at":"2015-04-24T01:28:31Z","updated_at":"2015-04-24T01:28:31Z","body":"Yep, that'll do it. You can also try `getCount()` to detect empty `Cursor` instances."}}