Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.
Ricky Tobing edited this page May 2, 2014 · 40 revisions

This Wiki is not proof-read

DbQuery is a library that extends the functionality of SQLiteOpenHelper and SQLiteDatabase to minimize the need to write SQL code inside your Java code

#Why The current way of querying in Android

Cursor cursor = 
  db.query("Customers",                            // table name
              new String[] {"Id", "Address", "Age"},  // columns
	      "Id IN (?,?,?)",                        // whereClause
	      new String[]{"" + customerId1, "" + customerId2, "" + customerId3},  // whereArgs
	      null,                                   // groupBy
	      null,                                   // having
	      "Age");                                 // orderBy

The purpose of DbQuery is to be able to write this query differently

Cursor cursor = 
   db.get("Customers")
     .select("Id IN (?,?,?)", customerId1, customerId2, customerId3) // whereClause
     .columns("Id", "Address", "Age")                                // columns
     .orderBy("Age")                                                 // orderBy 'Age'
     .query(); 

#Read On

Extensions Library

  • ContentQuery Allows DbQuery-style query to ContentProvider
  • DataProvider An extension library to help create a ContentProvider using existing IDatabase
Clone this wiki locally