Method getAllContacts
Method getAllContacts (Fig. 8.55) uses SqLiteDatabase’s query method (lines 83–84) to retrieve a Cursor that provides access to the IDs and names of all the contacts in the database. The arguments are:
• the name of the table to query.
• a String array of the column names to return (the _id and name columns here)—null returns all columns in the table, which is generally a poor programming practice, because to conserve memory, processor time and battery power, you should obtain only the data you need.
• a SQL WHERE clause (without the keyword WHERE), or null to return all rows.
• a String array of arguments to be substituted into the WHERE clause wherever ? is used as a placeholder for an argument value, or null if there ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access