当前位置: 首页>>代码示例>>Java>>正文


Java Data类代码示例

本文整理汇总了Java中android.provider.ContactsContract.Contacts.Data的典型用法代码示例。如果您正苦于以下问题:Java Data类的具体用法?Java Data怎么用?Java Data使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Data类属于android.provider.ContactsContract.Contacts包,在下文中一共展示了Data类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fillContactDataFromNameAndEmail

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
private boolean fillContactDataFromNameAndEmail(String query, List<Recipient> recipients,
        Map<String, Recipient> recipientMap) {
    query = "%" + query + "%";

    Uri queryUri = Email.CONTENT_URI;

    String selection = Contacts.DISPLAY_NAME_PRIMARY + " LIKE ? " +
            " OR (" + Email.ADDRESS + " LIKE ? AND " + Data.MIMETYPE + " = '" + Email.CONTENT_ITEM_TYPE + "')";
    String[] selectionArgs = { query, query };
    Cursor cursor = contentResolver.query(queryUri, PROJECTION, selection, selectionArgs, SORT_ORDER);

    if (cursor == null) {
        return false;
    }

    fillContactDataFromCursor(cursor, recipients, recipientMap);

    return true;

}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:21,代码来源:RecipientLoader.java

示例2: addContactToGroup

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
private static void addContactToGroup(ContentResolver mResolver, int contactId, int groupId)
{
    // judge whether the contact has been in the group
    boolean b1 = ifExistContactInGroup(mResolver, contactId, groupId);
    if (b1)
    {
        // the contact has been in the group
        return;
    }
    else
    {
        ContentValues values = new ContentValues();
        values.put(ContactsContract.CommonDataKinds.GroupMembership.RAW_CONTACT_ID, contactId);
        values.put(ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID, groupId);
        values.put(ContactsContract.CommonDataKinds.GroupMembership.MIMETYPE,
            ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE);
        mResolver.insert(ContactsContract.Data.CONTENT_URI, values);
    }
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:20,代码来源:AddressServiceImpl.java

示例3: ifExistContactInGroup

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
private static boolean ifExistContactInGroup(ContentResolver mResolver, int contactId, int groupId)
{
    String where =
        Data.MIMETYPE + " = '" + ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE + "' AND "
            + Data.DATA1 + " = '" + groupId + "' AND " + Data.RAW_CONTACT_ID + " = '" + contactId + "'";
    Cursor markCursor =
        mResolver.query(ContactsContract.Data.CONTENT_URI,
            new String[] {ContactsContract.Data.DISPLAY_NAME},
            where,
            null,
            null);
    if (markCursor.moveToFirst())
    {
        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:21,代码来源:AddressServiceImpl.java

示例4: fillContactDataFromQuery

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
private void fillContactDataFromQuery(String query, List<Recipient> recipients,
        Map<String, Recipient> recipientMap) {

    ContentResolver contentResolver = getContext().getContentResolver();

    query = "%" + query + "%";
    Uri queryUri = ContactsContract.CommonDataKinds.Email.CONTENT_URI;
    String selection = Contacts.DISPLAY_NAME_PRIMARY + " LIKE ? " +
            " OR (" + Email.ADDRESS + " LIKE ? AND " + Data.MIMETYPE + " = '" + Email.CONTENT_ITEM_TYPE + "')";
    String[] selectionArgs = { query, query };
    Cursor cursor = contentResolver.query(queryUri, PROJECTION, selection, selectionArgs, SORT_ORDER);

    if (cursor == null) {
        return;
    }

    fillContactDataFromCursor(cursor, recipients, recipientMap);

    if (observerContact != null) {
        observerContact = new ForceLoadContentObserver();
        contentResolver.registerContentObserver(queryUri, false, observerContact);
    }
}
 
开发者ID:scoute-dich,项目名称:K9-MailClient,代码行数:24,代码来源:RecipientLoader.java

示例5: onCreate

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_runset_screenslide_pager);
        setTitle("跑步设定");
         
        ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.list_item1, Data);
        ListView listView = (ListView) findViewById(R.id.runset_listview);
        listView.setAdapter(arrayAdapter);
        listView.setOnItemClickListener(this);
        
        // Instantiate a ViewPager and a PagerAdapter.
        
        mRunSetAdapter = new RunSetPagerAdapter(this);
        mPager = (ViewPager) findViewById(R.id.runset_pager);
//        mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
        mPager.setAdapter(mRunSetAdapter); 
        
        mBeginRunButton = (Button) findViewById(R.id.begin_run);
        mBeginRunButton.setOnClickListener(this);
        
    }
 
开发者ID:huazifoothole,项目名称:NikiRun,代码行数:23,代码来源:RunSetSlidePageActivity.java

示例6: delete

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
/**
 * 删除单个数据,会直接删除是这个名字的人的所有信息
 *
 * @param name 用户的姓名
 * @return 是否删除成功
 */
public boolean delete(String name) {
    try {
        //根据姓名求id
        Uri uri = Uri.parse("content://com.android.contacts/raw_contacts");
        //查询到name=“name”的集合
        Cursor cursor = mResolver.query(uri, new String[]{Data._ID},
                "display_name=?", new String[]{name}, null);
        if (cursor.moveToFirst()) {
            int id = cursor.getInt(0);
            //根据id删除data中的相应数据
            mResolver.delete(uri, "display_name=?", new String[]{name});
            uri = Uri.parse("content://com.android.contacts/data");
            mResolver.delete(uri, "raw_contact_id=?", new String[]{id + ""});
            return true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:luhaoaimama1,项目名称:zone-sdk,代码行数:27,代码来源:ContactsHelper.java

示例7: update

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
/**
 * 修改联系人数据
 */
public boolean update(String name, String phoneNumber) {
    try {
        //根据姓名求id,再根据id删除 
        Uri uri = Uri.parse("content://com.android.contacts/raw_contacts");
        Cursor cursor = mResolver.query(uri, new String[]{Data._ID}, "display_name=?", new String[]{name}, null);
        if (cursor.moveToFirst()) {
            int id = cursor.getInt(0);
            Uri mUri = Uri.parse("content://com.android.contacts/data");//对data表的所有数据操作
            ContentValues values = new ContentValues();
            values.put("data1", phoneNumber);
            mResolver.update(mUri, values, "mimetype=? and raw_contact_id=?", new String[]{"vnd.android.cursor.item/phone_v2", id + ""});
            return true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:luhaoaimama1,项目名称:zone-sdk,代码行数:22,代码来源:ContactsHelper.java

示例8: delete

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
/**
 * 删除单个数据,会直接删除是这个名字的人的所有信息
 *
 * @param name 用户的姓名
 * @return 是否删除成功
 */
public boolean delete(String name) {
    try {
        //根据姓名求id
        Uri uri = Uri.parse("content://com.android.contacts/raw_contacts");
        ContentResolver resolver = mContext.getContentResolver();
        //查询到name=“name”的集合
        Cursor cursor = resolver.query(uri, new String[]{Data._ID},
                "display_name=?", new String[]{name}, null);
        if (cursor.moveToFirst()) {
            int id = cursor.getInt(0);
            //根据id删除data中的相应数据
            resolver.delete(uri, "display_name=?", new String[]{name});
            uri = Uri.parse("content://com.android.contacts/data");
            resolver.delete(uri, "raw_contact_id=?", new String[]{id + ""});
            return true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:android-quick-dev,项目名称:NonViewUtils,代码行数:28,代码来源:ContactsHelper.java

示例9: update

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
/**
 * 修改联系人数据
 */
public boolean update(String name, String phoneNumber) {
    try {
        //根据姓名求id,再根据id删除 
        Uri uri = Uri.parse("content://com.android.contacts/raw_contacts");
        ContentResolver resolver = mContext.getContentResolver();
        Cursor cursor = resolver.query(uri, new String[]{Data._ID}, "display_name=?", new String[]{name}, null);
        if (cursor.moveToFirst()) {
            int id = cursor.getInt(0);
            Uri mUri = Uri.parse("content://com.android.contacts/data");//对data表的所有数据操作
            ContentResolver mResolver = mContext.getContentResolver();
            ContentValues values = new ContentValues();
            values.put("data1", phoneNumber);
            mResolver.update(mUri, values, "mimetype=? and raw_contact_id=?", new String[]{"vnd.android.cursor.item/phone_v2", id + ""});
            return true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:android-quick-dev,项目名称:NonViewUtils,代码行数:24,代码来源:ContactsHelper.java

示例10: getNicknameCursor

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
private Cursor getNicknameCursor(String nickname) {
    nickname = "%" + nickname + "%";

    Uri queryUriForNickname = ContactsContract.Data.CONTENT_URI;

    return contentResolver.query(queryUriForNickname,
            PROJECTION_NICKNAME,
            ContactsContract.CommonDataKinds.Nickname.NAME + " LIKE ? AND " +
                    Data.MIMETYPE + " = ?",
            new String[] { nickname, ContactsContract.CommonDataKinds.Nickname.CONTENT_ITEM_TYPE },
            null);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:13,代码来源:RecipientLoader.java

示例11: fillContactDataFromNickname

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions")
private boolean fillContactDataFromNickname(String nickname, List<Recipient> recipients,
        Map<String, Recipient> recipientMap) {

    boolean hasContact = false;

    Uri queryUri = Email.CONTENT_URI;

    Cursor nicknameCursor = getNicknameCursor(nickname);

    if (nicknameCursor == null) {
        return hasContact;
    }

    try {
        while (nicknameCursor.moveToNext()) {
            String id = nicknameCursor.getString(INDEX_CONTACT_ID_FOR_NICKNAME);
            String selection = ContactsContract.Data.CONTACT_ID + " = ?";
            Cursor cursor = contentResolver
                    .query(queryUri, PROJECTION, selection, new String[] { id }, SORT_ORDER);

            String contactNickname = nicknameCursor.getString(INDEX_NICKNAME);
            fillContactDataFromCursor(cursor, recipients, recipientMap, contactNickname);

            hasContact = true;
        }
    } finally {
        nicknameCursor.close();
    }

    return hasContact;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:33,代码来源:RecipientLoader.java

示例12: AddContact

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
public static void AddContact(ContentResolver mResolver, String name, String number, String groupName)
{
    Log.i("hoperun", "name= " + name + ";number=" + number);
    if (!queryFromContact(mResolver, name, number))
    {
        ContentValues values = new ContentValues();
        // 首先向RawContacts.CONTENT_URI执行一个空值插入,目的是获取系统返回的rawContactId
        Uri rawContactUri = mResolver.insert(RawContacts.CONTENT_URI, values);
        
        if (rawContactUri != null)
        {
            long rawContactId = ContentUris.parseId(rawContactUri);
            // 往data表插入姓名数据
            values.clear();
            values.put(Data.RAW_CONTACT_ID, rawContactId);
            values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);// 内容类型
            values.put(StructuredName.GIVEN_NAME, name);
            mResolver.insert(ContactsContract.Data.CONTENT_URI, values);
            // 往data表插入电话数据
            values.clear();
            values.put(Data.RAW_CONTACT_ID, rawContactId);
            values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
            values.put(Phone.NUMBER, number);
            values.put(Phone.TYPE, Phone.TYPE_MOBILE);
            mResolver.insert(ContactsContract.Data.CONTENT_URI, values);
        }
        else
        {
            Log.i("hoperun", "name= " + name + ";number=" + number);
        }
        
    }
    else
    {
        Log.i("hoperun", "repeat name= " + name + ";number=" + number);
    }
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:38,代码来源:AddressServiceImpl.java

示例13: insertContact

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
/**
 * 往手机通讯录插入联系人
 *
 * @param ct
 * @param name
 * @param tel
 * @param email
 */
public static void insertContact(Context ct, String name, String tel, String email) {
    ContentValues values = new ContentValues();
    // 首先向RawContacts.CONTENT_URI执行一个空值插入,目的是获取系统返回的rawContactId
    Uri rawContactUri = ct.getContentResolver().insert(RawContacts.CONTENT_URI, values);
    long rawContactId = ContentUris.parseId(rawContactUri);
    // 往data表入姓名数据
    if (!TextUtils.isEmpty(tel)) {
        values.clear();
        values.put(Data.RAW_CONTACT_ID, rawContactId);
        values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);// 内容类型
        values.put(StructuredName.GIVEN_NAME, name);
        ct.getContentResolver().insert(android.provider.ContactsContract.Data.CONTENT_URI, values);
    }
    // 往data表入电话数据
    if (!TextUtils.isEmpty(tel)) {
        values.clear();
        values.put(Data.RAW_CONTACT_ID, rawContactId);
        values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);// 内容类型
        values.put(Phone.NUMBER, tel);
        values.put(Phone.TYPE, Phone.TYPE_MOBILE);
        ct.getContentResolver().insert(android.provider.ContactsContract.Data.CONTENT_URI, values);
    }
    // 往data表入Email数据
    if (!TextUtils.isEmpty(email)) {
        values.clear();
        values.put(Data.RAW_CONTACT_ID, rawContactId);
        values.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);// 内容类型
        values.put(Email.DATA, email);
        values.put(Email.TYPE, Email.TYPE_WORK);
        ct.getContentResolver().insert(android.provider.ContactsContract.Data.CONTENT_URI, values);
    }
}
 
开发者ID:huashengzzz,项目名称:SmartChart,代码行数:41,代码来源:CommonUtils.java

示例14: onCreateLoader

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String[] columns = {Phone._ID, Phone.DISPLAY_NAME_PRIMARY, Phone.DATA};
    String selection = Data.MIMETYPE + " = '" + Phone.CONTENT_ITEM_TYPE + "'";
    String orderBy = Phone.DISPLAY_NAME_PRIMARY + " ASC";
    return new CursorLoader(this, Phone.CONTENT_URI, columns, selection, null, orderBy);
}
 
开发者ID:Egorand,项目名称:android-testing-runtime-permissions,代码行数:8,代码来源:MainActivity.java

示例15: insert

import android.provider.ContactsContract.Contacts.Data; //导入依赖的package包/类
/**
 * 添加一个联系人数据
 *
 * @return 返回true表示添加成功,false表示失败
 */
public boolean insert(String name, String phoneNumber) {
    //根据号码找数据,如果存在则不添加
    if (getNameByPhoneNumber(phoneNumber) == null) {
        //插入raw_contacts表,并获取_id属性
        Uri uri = Uri.parse("content://com.android.contacts/raw_contacts");
        ContentResolver resolver = mContext.getContentResolver();
        ContentValues values = new ContentValues();
        long contact_id = ContentUris.parseId(resolver.insert(uri, values));
        //插入data表
        uri = Uri.parse("content://com.android.contacts/data");
        //添加姓名
        values.put("raw_contact_id", contact_id);
        values.put(Data.MIMETYPE, "vnd.android.cursor.item/name");
        values.put("data2", name);
        resolver.insert(uri, values);
        values.clear();
        //添加手机号码
        values.put("raw_contact_id", contact_id);
        values.put(Data.MIMETYPE, "vnd.android.cursor.item/phone_v2");
        values.put("data2", "2");    //2表示手机
        values.put("data1", phoneNumber);
        resolver.insert(uri, values);
        values.clear();
        return true;
    } else {
        return false;
    }
}
 
开发者ID:lujianzhao,项目名称:AndroidBase,代码行数:34,代码来源:ContactsHelper.java


注:本文中的android.provider.ContactsContract.Contacts.Data类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。