SQLiteQueryBuilder setDistinct - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SQLiteQueryBuilder setDistinct method.

This code example shows how to use the following methods:query, setDistinct, setProjectionMap, setTables
	return query(selection, selectionArgs, columns, true, KEY_CLASS_ID);
    } 
 
    private Cursor query(String selection, String[] selectionArgs,
	    String[] columns, boolean distinct, String groupBy) {
	SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
	builder.setTables(DATABASE_TABLE_NAME);
	builder.setProjectionMap(mColumnMap);
	builder.setDistinct(distinct);
	SQLiteDatabase db = mDatabaseOpenHelper.getReadableDatabase();
	Cursor cursor = builder.query(db, columns, selection, selectionArgs,
		groupBy, null, null);
	if (cursor == null) {
	    Log.d(TAG,
		    "-------------------cursor is null-------------------------"); 
	    return null; 
	} else if (!cursor.moveToFirst()) {
	    Log.d(TAG,
		    "-------------------cursor move first fail------cursor.getCount()=" 
			    + cursor.getCount());
6
CodeRank
This code example shows how to use the following methods:query, setDistinct, setTables
		} 
	} 
 
	@Override 
	public int getCategoryNum() { 
		SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
		queryBuilder.setTables(LibraryTable.getTableName());
		queryBuilder.setDistinct(true);
		Cursor cursor = queryBuilder.query(sdb,
				new String[] { LibraryTable.category.getColumnName() }, null,
				null, null, null, null); 
		int count = cursor.getCount();
		cursor.close();
		return count;
	} 
 
	@Override 
	public Uri getPublisherIconUri(Book book) {
		SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
		queryBuilder.setTables(PublisherTable.getTableName());
5
CodeRank
This code example shows how to use the following methods:appendWhere, buildQuery, query, setDistinct, setProjectionMap
				+ Arrays.toString(projection) + ", selection=" + selection
				+ ", selectionArgs=" + Arrays.toString(selectionArgs)
				+ ", sortOrder=" + sortOrder);
 
		SQLiteDatabase db = mDbHelper.getReadableDatabase();
		SQLiteQueryBuilder qBuilder = new SQLiteQueryBuilder();
		qBuilder.setTables(getTablesForUri(uri));
		qBuilder.setProjectionMap(getProjectionMapForUri(uri, projection));
		String where = getAddionalWhereClausesForUri(uri);
		qBuilder.setDistinct(isDistinct(uri));
		if (where != null) {
			qBuilder.appendWhere(where);
		} 
		if (sortOrder != null) {
			sortOrder = disambiguateSortOrder(uri, sortOrder);
		} 
 
		Log.d(TAG, "Doing query: "
				+ qBuilder.buildQuery(projection, selection, null, // groupBy,
						null, // having, 

5
CodeRank
This code example shows how to use the following methods:appendWhere, query, setDistinct, setTables
		return true; 
	} 
	 
	@Override 
	public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
		SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
		int uriType = sURIMatcher.match(uri);
		 
	    switch (uriType) {
	    case COLLECTION_FROM_ALL_FOLDERS: // Collection from All Folders
	    	queryBuilder.setTables("collection INNER JOIN games ON collection.game_id = games._id " +
	    			"LEFT JOIN consoles ON games.console_id = consoles._id"); 
	    	queryBuilder.setDistinct(true);
	    	break; 
	    case COLLECTION_FROM_OWNED_FOLDERS: // Collection from Owned Folders
	    	queryBuilder.setTables("collection INNER JOIN games ON collection.game_id = games._id " +
    			"INNER JOIN folders ON collection.folder_id = folders._id " + 
				"LEFT JOIN consoles ON games.console_id = consoles._id"); 
    		queryBuilder.appendWhere("is_owned = 1");
    		queryBuilder.setDistinct(true);

4
CodeRank

Related SQLiteQueryBuilder setDistinct Questions & Answers:

setDistinct Method Overview
Mark the query as DISTINCT.
See Code Examples for other Android SQLiteQueryBuilder Methods: