Java Code Examples for android.provider.ContactsContract.Data#MIMETYPE

The following examples show how to use android.provider.ContactsContract.Data#MIMETYPE . 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: ContactsManager.java    From Linphone4Android with GNU General Public License v3.0 5 votes vote down vote up
private Cursor getContactsCursor(ContentResolver cr) {
	String req = "(" + Data.MIMETYPE + " = '" + CommonDataKinds.Phone.CONTENT_ITEM_TYPE
			+ "' AND " + CommonDataKinds.Phone.NUMBER + " IS NOT NULL "
			+ " OR (" + Data.MIMETYPE + " = '" + CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE
			+ "' AND " + CommonDataKinds.SipAddress.SIP_ADDRESS + " IS NOT NULL))";
	String[] projection = new String[] { Data.CONTACT_ID, Data.DISPLAY_NAME };
	String query = Data.DISPLAY_NAME + " IS NOT NULL AND (" + req + ")";

	Cursor cursor = cr.query(Data.CONTENT_URI, projection, query, null, " lower(" + Data.DISPLAY_NAME + ") COLLATE UNICODE ASC");
	if (cursor == null) {
		return cursor;
	}

	MatrixCursor result = new MatrixCursor(cursor.getColumnNames());
	Set<String> groupBy = new HashSet<String>();
	while (cursor.moveToNext()) {
	    String name = cursor.getString(cursor.getColumnIndex(Data.DISPLAY_NAME));
	    if (!groupBy.contains(name)) {
	    	groupBy.add(name);
	    	Object[] newRow = new Object[cursor.getColumnCount()];

	    	int contactID = cursor.getColumnIndex(Data.CONTACT_ID);
	    	int displayName = cursor.getColumnIndex(Data.DISPLAY_NAME);

	    	newRow[contactID] = cursor.getString(contactID);
	    	newRow[displayName] = cursor.getString(displayName);

	        result.addRow(newRow);
    	}
    }
	cursor.close();
	return result;
}
 
Example 2
Source File: ContactsUtils5.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<String> getCSipPhonesContact(Context ctxt, Long contactId) {
    ArrayList<String> results = new ArrayList<String>();
    Uri dataUri = Data.CONTENT_URI;
    String dataQuery = Data.MIMETYPE + "='" + CommonDataKinds.Im.CONTENT_ITEM_TYPE + "' "
            + " AND "
            + CommonDataKinds.Im.PROTOCOL + "=" + CommonDataKinds.Im.PROTOCOL_CUSTOM
            + " AND "
            + " LOWER(" + CommonDataKinds.Im.CUSTOM_PROTOCOL + ")='"+SipManager.PROTOCOL_CSIP+"'";
    // get csip data
    Cursor dataCursor = ctxt.getContentResolver()
            .query(dataUri,
                    new String[] {
                            CommonDataKinds.Im._ID,
                            CommonDataKinds.Im.DATA,
                    },
                    dataQuery + " AND " + CommonDataKinds.Im.CONTACT_ID + "=?",
                    new String[] {
                        Long.toString(contactId)
                    }, null);

    try {
        if (dataCursor != null && dataCursor.getCount() > 0) {
            dataCursor.moveToFirst();
            String val = dataCursor.getString(dataCursor
                    .getColumnIndex(CommonDataKinds.Im.DATA));
            if (!TextUtils.isEmpty(val)) {
                results.add(val);
            }
        }
    } catch (Exception e) {
        Log.e(THIS_FILE, "Error while looping on data", e);
    } finally {
        dataCursor.close();
    }
    
    return results;
}
 
Example 3
Source File: HoneycombMR1Util.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Get the DATA_PROJECTION for ContactPicker and PhoneNumberPicker.
 */
public static String[] getDataProjection() {
  String[] dataProjection = {
    Data.MIMETYPE,
    Email.ADDRESS,
    Email.TYPE,
    Phone.NUMBER,
    Phone.TYPE,
  };
  return dataProjection;
}
 
Example 4
Source File: HoneycombMR1Util.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Get the NEW_PROJECTION for EmailAddressAdapter.
 */
public static String[] getEmailAdapterProjection() {
  String[] emailAdapterProjection = {
    Data._ID,
    Data.DISPLAY_NAME,
    Email.ADDRESS,
    Data.MIMETYPE,
  };
  return emailAdapterProjection;
}
 
Example 5
Source File: AndroidContact.java    From linphone-android with GNU General Public License v3.0 5 votes vote down vote up
boolean isLinphoneAddressMimeEntryAlreadyExisting(String value) {
    boolean result = false;

    ContentResolver resolver =
            LinphoneContext.instance().getApplicationContext().getContentResolver();
    String[] projection = {"data1", "data3"};
    String selection =
            ContactsContract.Data.RAW_CONTACT_ID
                    + " = ? AND "
                    + Data.MIMETYPE
                    + " = ? AND data1 = ?";

    Cursor c =
            resolver.query(
                    ContactsContract.Data.CONTENT_URI,
                    projection,
                    selection,
                    new String[] {
                        mAndroidRawId,
                        ContactsManager.getInstance()
                                .getString(R.string.linphone_address_mime_type),
                        value
                    },
                    null);
    if (c != null) {
        if (c.moveToFirst()) {
            result = true;
        }
        c.close();
    }
    return result;
}
 
Example 6
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 7
Source File: HoneycombMR1Util.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Get Data.MIMETYPE for EmailAddressAdapter.
 */
public static String getDataMimeType() {
  return Data.MIMETYPE;
}