Java Code Examples for android.provider.ContactsContract.Contacts#STARRED

The following examples show how to use android.provider.ContactsContract.Contacts#STARRED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContactsListActivity.java    From coursera-android with MIT License 6 votes vote down vote up
private void loadContacts() {

        // Contact data
        String columnsToExtract[] = new String[] { Contacts._ID,
                Contacts.DISPLAY_NAME, Contacts.PHOTO_THUMBNAIL_URI };

        // Get the ContentResolver
        ContentResolver contentResolver = getContentResolver();

        // filter contacts with empty names
        String whereClause = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
                + Contacts.DISPLAY_NAME + " != '' ) AND (" + Contacts.STARRED
                + "== 1))";

        // sort by increasing ID
        String sortOrder = Contacts._ID + " ASC";

        // query contacts ContentProvider
        mCursor = contentResolver.query(Contacts.CONTENT_URI,
                columnsToExtract, whereClause, null, sortOrder);

        // pass mCursor to custom list adapter
        setListAdapter(new ContactInfoListAdapter(this, R.layout.list_item,
                mCursor, 0));

    }
 
Example 2
Source File: QueryContactsCommand.java    From mobilecloud-15 with Apache License 2.0 5 votes vote down vote up
/**
 * Synchronously query for contacts in the Contacts
 * ContentProvider.
 */
public Cursor queryAllContacts(ContentResolver cr) {
    // Columns to query.
    final String columnsToQuery[] =
        new String[] {
        ContactsContract.Contacts._ID,
        ContactsContract.Contacts.DISPLAY_NAME,
        ContactsContract.Contacts.STARRED 
    };
	
    // Contacts to select.
    final String selection = 
        "((" 
        + Contacts.DISPLAY_NAME 
        + " NOTNULL) AND ("
        + Contacts.DISPLAY_NAME 
        + " != '' ) AND (" 
        + Contacts.STARRED
        + "== 1))";

    // Perform a synchronous (blocking) query on the
    // ContactsContentProvider.
    return cr.query(ContactsContract.RawContacts.CONTENT_URI, 
                    columnsToQuery, 
                    selection,
                    null, 
                    ContactsContract.Contacts._ID
                    + " ASC");
}
 
Example 3
Source File: QueryContactsCommand.java    From mobilecloud-15 with Apache License 2.0 5 votes vote down vote up
/**
 * Asynchronously query the contacts based on selection
 * criteria.
 */
@Override
public void execute() {
    // Columns to query.
    final String columnsToQuery[] = 
        new String[] {
        ContactsContract.Contacts._ID,
        ContactsContract.Contacts.DISPLAY_NAME,
        ContactsContract.Contacts.STARRED 
    };

    // Contacts to select.
    final String selection = 
        "((" 
        + Contacts.DISPLAY_NAME 
        + " NOTNULL) AND ("
        + Contacts.DISPLAY_NAME 
        + " != '' ) AND (" 
        + Contacts.STARRED
        + "== 1))";

    // Initiate an asynchronous query.
    getArgs().getAdapter()
             .startQuery(this,
                         0,
                         ContactsContract.Contacts.CONTENT_URI, 
                         columnsToQuery, 
                         selection,
                         // ContactsContract.Contacts.STARRED /* + "= 0" */,
                         null, 
                         ContactsContract.Contacts._ID
                         + " ASC");        
}
 
Example 4
Source File: QueryContactsCommand.java    From mobilecloud-15 with Apache License 2.0 5 votes vote down vote up
/**
 * This hook method is called back by the LoaderManager when the
 * LoaderManager is initialized.
 */
public Loader<Cursor> onCreateLoader(int id, 
                                     Bundle args) {
    // Columns to query.
    final String columnsToQuery[] =
        new String[] {
        ContactsContract.Contacts._ID,
        ContactsContract.Contacts.DISPLAY_NAME,
        ContactsContract.Contacts.STARRED 
    };
	
    // Contacts to select.
    final String selection =
        "((" 
        + Contacts.DISPLAY_NAME 
        + " NOTNULL) AND ("
        + Contacts.DISPLAY_NAME 
        + " != '' ) AND (" 
        + Contacts.STARRED
        + "== 1))";

    // Create a new CursorLoader that will perform the query
    // asynchronously.
    return new CursorLoader(mOps.getActivityContext(),
                            ContactsContract.Contacts.CONTENT_URI,
                            columnsToQuery,
                            selection,
                            null,
                            Contacts._ID 
                            + " ASC");
}
 
Example 5
Source File: FavoritesFragmentContainer.java    From Contacts with MIT License 5 votes vote down vote up
@Override
protected String getAdditionalFilters()
{
	if (mPosition == 0)
	{
		return " AND " + Contacts.STARRED + " = " + 1;
	}
	else
	{
		return " AND " + Data.MIMETYPE + " = ? AND " + CommonDataKinds.GroupMembership.GROUP_ROW_ID + " = ?";
	}
}
 
Example 6
Source File: DisplayActivity.java    From coursera-android with MIT License 5 votes vote down vote up
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

		String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
				+ Contacts.DISPLAY_NAME + " != '' ) AND (" + Contacts.STARRED
				+ "== 1))";

		return new CursorLoader(this, Contacts.CONTENT_URI, columnsToExtract,
				select, null, Contacts._ID + " ASC");
	}
 
Example 7
Source File: ContactsListExample.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	// Contact data
	String columnsToExtract[] = new String[] { Contacts._ID,
			Contacts.DISPLAY_NAME, Contacts.PHOTO_THUMBNAIL_URI };

	// Get the ContentResolver
	ContentResolver contentResolver = getContentResolver();

	// filter contacts with empty names
	String whereClause = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
			+ Contacts.DISPLAY_NAME + " != '' ) AND (" + Contacts.STARRED
			+ "== 1))";

	// sort by increasing ID
	String sortOrder = Contacts._ID + " ASC";

	// query contacts ContentProvider
	Cursor cursor = contentResolver.query(Contacts.CONTENT_URI,
			columnsToExtract, whereClause, null, sortOrder);

	// pass cursor to custom list adapter
	setListAdapter(new ContactInfoListAdapter(this, R.layout.list_item,
			cursor, 0));
}
 
Example 8
Source File: ContactsListExample.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

	// String used to filter contacts with empty or missing names or are unstarred
	String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
			+ Contacts.DISPLAY_NAME + " != '' ) AND (" + Contacts.STARRED
			+ "== 1))";

	// String used for defining the sort order
	String sortOrder = Contacts._ID + " ASC";

	return new CursorLoader(this, Contacts.CONTENT_URI, CONTACTS_ROWS,
			select, null, sortOrder);
}
 
Example 9
Source File: DisplayActivity.java    From coursera-android with MIT License 5 votes vote down vote up
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

        String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
                + Contacts.DISPLAY_NAME + " != '' ) AND (" + Contacts.STARRED
                + "== 1))";

        return new CursorLoader(this, Contacts.CONTENT_URI, columnsToExtract,
                select, null, Contacts._ID + " ASC");
    }
 
Example 10
Source File: ContactsListExample.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	// Contact data
	String columnsToExtract[] = new String[] { Contacts._ID,
			Contacts.DISPLAY_NAME, Contacts.PHOTO_THUMBNAIL_URI };

	// Get the ContentResolver
	ContentResolver contentResolver = getContentResolver();

	// filter contacts with empty names
	String whereClause = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
			+ Contacts.DISPLAY_NAME + " != '' ) AND (" + Contacts.STARRED
			+ "== 1))";

	// sort by increasing ID
	String sortOrder = Contacts._ID + " ASC";

	// query contacts ContentProvider
	Cursor cursor = contentResolver.query(Contacts.CONTENT_URI,
			columnsToExtract, whereClause, null, sortOrder);

	// pass cursor to custom list adapter
	setListAdapter(new ContactInfoListAdapter(this, R.layout.list_item,
			cursor, 0));
}
 
Example 11
Source File: ContactsListActivity.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    // String used to filter contacts with empty or missing names or are unstarred
    String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
            + Contacts.DISPLAY_NAME + " != '' ) AND (" + Contacts.STARRED
            + "== 1))";

    // String used for defining the sort order
    String sortOrder = Contacts._ID + " ASC";

    return new CursorLoader(this, Contacts.CONTENT_URI, CONTACTS_ROWS,
            select, null, sortOrder);
}