Code example for SQLiteQueryBuilder

Methods: appendWhere, query, setTables

0
            String[] selectionArgs, String groupBy, String having, String sortOrder) {
        // We won't bother checking the validity of params here, but you should! 
 
        // SQLiteQueryBuilder is the helper class that creates the 
        // proper SQL syntax for us. 
        SQLiteQueryBuilder qBuilder = new SQLiteQueryBuilder();
 
        // Set the table we're querying. 
        qBuilder.setTables(DATABASE_TABLE_NAME);
 
        // If the query ends in a specific record number, we're 
        // being asked for a specific record, so set the 
        // WHERE clause in our query. 
        if((URI_MATCHER.match(uri)) == SPECIFIC_MESSAGE){
            qBuilder.appendWhere("_id=" + uri.getPathLeafId());
        } 
 
        // Set sort order. If none specified, use default. 
        if(TextUtils.isEmpty(sortOrder)){
            sortOrder = DEFAULT_SORT_ORDER;
        } 
 
        // Make the query. 
        Cursor c = qBuilder.query(mDb,
                projection,
                selection,
                selectionArgs,
                groupBy,
                having,