Search code examples
androidsqlitesqlbrite

SQLBrite how to pass parameter to createQuery


I am using sqlbrite for my chatting app. I need to observe a database, but the range is not fixed.

Observable<Query> messages = db.createQuery("messages", "SELECT * FROM users WHERE timestamp > ? ");

I need to pass in an argument newestMessage.sentTime, but newestMessage keeps updating as soon as a new message comes. So I cant just pass in the current newestMessage as argument.


Solution

  • The results of a single query execution never change and represent a snapshot. To get more messages, you have to re-execute the query, i.e., call createQuery again.