Reading from the Database

Reading in data from SQLite is done using the query(…) method. SQLiteDatabase.query(…) has quite a lot going on. There are a few different overloads of this method. The one you will be using looks like this:

p​u​b​l​i​c​ ​C​u​r​s​o​r​ ​q​u​e​r​y​(​
 ​ ​ ​ ​S​t​r​i​n​g​ ​t​a​b​l​e​,​
 ​ ​ ​ ​S​t​r​i​n​g​[​]​ ​c​o​l​u​m​n​s​,​
 ​ ​ ​ ​S​t​r​i​n​g​ ​w​h​e​r​e​,​
 ​ ​ ​ ​S​t​r​i​n​g​[​]​ ​w​h​e​r​e​A​r​g​s​,​
 ​ ​ ​ ​S​t​r​i​n​g​ ​g​r​o​u​p​B​y​,​
 ​ ​ ​ ​S​t​r​i​n​g​ ​h​a​v​i​n​g​,​
 ​ ​ ​ ​S​t​r​i​n​g​ ​o​r​d​e​r​B​y​,​
 ​ ​ ​ ​S​t​r​i​n​g​ ​l​i​m​i​t​)​

If you have dealt with SQL before, then most of these will be familiar to you as arguments of the select statement. If you have not, then you only need to worry ...

Get Android Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.