Java 类android.provider.ContactsContract.CommonDataKinds.Note 实例源码

项目:mc_backup    文件:ContactService.java   
private void initColumnNameConstantsMap() {
    if (mColumnNameConstantsMap != null) {
        return;
    }
    mColumnNameConstantsMap = new HashMap<String, String>();

    mColumnNameConstantsMap.put("name", StructuredName.DISPLAY_NAME);
    mColumnNameConstantsMap.put("givenname", StructuredName.GIVEN_NAME);
    mColumnNameConstantsMap.put("familyname", StructuredName.FAMILY_NAME);
    mColumnNameConstantsMap.put("honorificprefix", StructuredName.PREFIX);
    mColumnNameConstantsMap.put("honorificsuffix", StructuredName.SUFFIX);
    mColumnNameConstantsMap.put("additionalname", CUSTOM_DATA_COLUMN);
    mColumnNameConstantsMap.put("nickname", Nickname.NAME);
    mColumnNameConstantsMap.put("adr", StructuredPostal.STREET);
    mColumnNameConstantsMap.put("email", Email.ADDRESS);
    mColumnNameConstantsMap.put("url", Website.URL);
    mColumnNameConstantsMap.put("category", GroupMembership.GROUP_ROW_ID);
    mColumnNameConstantsMap.put("tel", Phone.NUMBER);
    mColumnNameConstantsMap.put("org", Organization.COMPANY);
    mColumnNameConstantsMap.put("jobTitle", Organization.TITLE);
    mColumnNameConstantsMap.put("note", Note.NOTE);
    mColumnNameConstantsMap.put("impp", Im.DATA);
    mColumnNameConstantsMap.put("sex", CUSTOM_DATA_COLUMN);
    mColumnNameConstantsMap.put("genderidentity", CUSTOM_DATA_COLUMN);
    mColumnNameConstantsMap.put("key", CUSTOM_DATA_COLUMN);
}
项目:mc_backup    文件:ContactService.java   
private void initMimeTypeConstantsMap() {
    if (mMimeTypeConstantsMap != null) {
        return;
    }
    mMimeTypeConstantsMap = new HashMap<String, String>();

    mMimeTypeConstantsMap.put("name", StructuredName.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("givenname", StructuredName.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("familyname", StructuredName.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("honorificprefix", StructuredName.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("honorificsuffix", StructuredName.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("additionalname", MIMETYPE_ADDITIONAL_NAME);
    mMimeTypeConstantsMap.put("nickname", Nickname.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("email", Email.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("url", Website.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("category", GroupMembership.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("tel", Phone.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("org", Organization.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("jobTitle", Organization.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("note", Note.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("impp", Im.CONTENT_ITEM_TYPE);
    mMimeTypeConstantsMap.put("sex", MIMETYPE_SEX);
    mMimeTypeConstantsMap.put("genderidentity", MIMETYPE_GENDER_IDENTITY);
    mMimeTypeConstantsMap.put("key", MIMETYPE_KEY);
}
项目:JCB    文件:ContactUtils.java   
private String getNote(String contactId) {
    Cursor cursor = cr.query(Data.CONTENT_URI, new String[] { Data._ID,
            Note.NOTE }, Data.CONTACT_ID + "=?" + " AND " + Data.MIMETYPE
            + "='" + Note.CONTENT_ITEM_TYPE + "'",
            new String[] { contactId }, null);
    StringBuffer sb = new StringBuffer();
    if (cursor.moveToFirst()) {

        do {
            String noteinfo = cursor.getString(cursor
                    .getColumnIndex(Note.NOTE));
            sb.append(noteinfo);
        } while (cursor.moveToNext());
    } else {
        sb.append("");
    }
    cursor.close();
    return sb.toString();
}
项目:assistance-platform-client-sdk-android    文件:ContactsSensor.java   
private String getNote(String contactId, ContentProviderClient namesContentClient) {

        if (contactId == null || namesContentClient == null || context == null) {
            return null;
        }

        String note = "";
        String[] whereParameters = {contactId, Note.CONTENT_ITEM_TYPE};

        Cursor contacts = null;

        try {

            contacts = namesContentClient
                    .query(URI_DATA, columnsNote, whereNote, whereParameters, null);

            if (contacts != null && contacts.moveToFirst()) {
                note = getStringByColumnName(contacts, Note.NOTE);
            }

        } catch (Exception e) {
            Log.d(TAG, "Some error in getNote");
        } finally {
            if (contacts != null) {
                contacts.close();
            }
        }

        return note;
    }
项目:mc_backup    文件:ContactService.java   
private void getNotesValues(final JSONArray notes, List<ContentValues> newContactValues) throws JSONException {
    if (notes == null) {
        return;
    }

    for (int i = 0; i < notes.length(); i++) {
        ContentValues contentValues = new ContentValues();
        contentValues.put(Data.MIMETYPE, Note.CONTENT_ITEM_TYPE);
        contentValues.put(Note.NOTE, notes.getString(i));
        newContactValues.add(contentValues);
    }
}
项目:ntsync-android    文件:ContactOperations.java   
public ContactOperations addNote(String note) {
    mValues.clear();
    if (!TextUtils.isEmpty(note)) {
        mValues.put(Note.NOTE, note);
        mValues.put(Note.MIMETYPE, Note.CONTENT_ITEM_TYPE);
        addInsertOp();
    }
    return this;
}
项目:ntsync-android    文件:ContactOperations.java   
public ContactOperations updateNote(String note, Uri uri) {
    mValues.clear();
    mValues.put(Note.NOTE, note);
    mValues.put(Note.MIMETYPE, Note.CONTENT_ITEM_TYPE);
    addUpdateOp(uri);

    return this;
}
项目:CucumberSync    文件:LocalAddressBook.java   
protected void populateNote(Contact c) throws RemoteException {
    @Cleanup Cursor cursor = providerClient.query(dataURI(), new String[] { Note.NOTE },
            Note.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
            new String[] { String.valueOf(c.getLocalID()), Note.CONTENT_ITEM_TYPE }, null);
    if (cursor != null && cursor.moveToNext())
        c.setNote(cursor.getString(0));
}
项目:JCB    文件:ContactUtils.java   
public void addNote(String note) {
    ops.add(ContentProviderOperation
            .newInsert(android.provider.ContactsContract.Data.CONTENT_URI)
            .withValueBackReference(Data.RAW_CONTACT_ID,
                    rawContactInsertIndex)
            .withValue(Data.MIMETYPE, Note.CONTENT_ITEM_TYPE)
            .withValue(Note.NOTE, note).build());

}
项目:openxface-android    文件:XContactAccessorAPILevel5Impl.java   
@Override
public void cursorToHashMap(Map<String, Object> contactsMap, Cursor c) {
    // 获取当前行的 mimetype用于比较
    String mimetype = c.getString(c
            .getColumnIndex(ContactsContract.Data.MIMETYPE));

    if (StructuredName.CONTENT_ITEM_TYPE.equals(mimetype)) {
        contactsMap.put(LOGIC_FIELD_DISPLAYNAME,
                c.getString(c.getColumnIndex(StructuredName.DISPLAY_NAME)));
        nameQuery(contactsMap, c);
    } else if (Event.CONTENT_ITEM_TYPE.equals(mimetype)) {
        if (Event.TYPE_BIRTHDAY == c.getInt(c.getColumnIndex(Event.TYPE))) {
            contactsMap.put(LOGIC_FIELD_BIRTHDAY,
                    c.getString(c.getColumnIndex(Event.START_DATE)));
        }
    } else if (Nickname.CONTENT_ITEM_TYPE.equals(mimetype)) {
        contactsMap.put(LOGIC_FIELD_NICKNAME,
                c.getString(c.getColumnIndex(Nickname.NAME)));
    } else if (Note.CONTENT_ITEM_TYPE.equals(mimetype)) {
        contactsMap.put(LOGIC_FIELD_NOTE,
                c.getString(c.getColumnIndex(Note.NOTE)));
    } else {
        String logicField = LOGIC_FIELD_TO_CONTENT_TYPE_MAP
                .getKeyByValue(mimetype);
        if (LOGIC_CONTACT_MULTIPLE_VALUE_FIELDS.contains(logicField)) {
            multipleValueFieldQuery(contactsMap, c, logicField);
        }
    }
}
项目:CucumberSync    文件:LocalAddressBook.java   
protected Builder buildNote(Builder builder, String note) {
    return builder
        .withValue(Data.MIMETYPE, Note.CONTENT_ITEM_TYPE)
        .withValue(Note.NOTE, note);
}
项目:open-note    文件:DeleteNotesOperation.java   
@Override
public Bundle execute(Context context, Request request) throws ConnectionException, DataException, CustomRequestException {
    String host = context.getString(R.string.host_name);
    int length = request.getInt("length");
    String address = "http://" + host + "/api/snote/";

    NetworkConnection connection = new NetworkConnection(context, address);
    ArrayList<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
    String sessionHash = request.getString("session_hash");
    params.add( new BasicNameValuePair("session_hash", sessionHash) );
    List<String> IDs = new ArrayList<String>();
    for(int i=0; i<length; i++){
        String id = String.valueOf( request.getLong("id"+i) );
        IDs.add(id);
        params.add(new BasicNameValuePair("id", id));
    }
    connection.setParameters(params);

    String where = "(";
    for (int i=0; i<IDs.size(); i++){
        where += "?,";
    }
    where = where.substring(0, where.length()-1) + ")";

    connection.setMethod(Method.DELETE);
    ConnectionResult result = connection.execute();

    try {
        JSONObject JSONRoot = new JSONObject(result.body);
        JSONObject JSONStatus = JSONRoot.getJSONObject("status");

        int code = JSONStatus.getInt("code");
        if (code < 200 || code >= 300){
            throw new JSONException("ok message not found");
        }
    } catch (JSONException e) {
        throw new CustomRequestException(result.body) {
            private static final long serialVersionUID = 1L;
        };
    }

    context.getContentResolver().delete(
            RestContact.Note.CONTENT_URI
            , Note._ID+" in " + where
            , IDs.toArray( new String[IDs.size()] )
    );

    return null;
}