Android手机系统的手机功能开发例子
view.findViewById(R.id.insert_contacts_layout_edittext_username);
peopleName_editText.setText(peopleName);
final EditText phoneNumber_editText = (EditText) view.findViewById(R.id.insert_contacts_layout_edittext_password);
phoneNumber_editText.setText(phoneNumber);
final AlertDialog.Builder myBuilder = new AlertDialog.Builder(this);
myBuilder.setIcon(android.R.drawable.ic_dialog_info);
myBuilder.setTitle(R.string.updateContacts);
myBuilder.setView(view);
myBuilder.setPositiveButton(R.string.certain,new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) {
String getPeopleName = peopleName_editText.getText().toString(); String getPhoneNum = phoneNumber_editText.getText().toString();
//得到当前选择的联系人的Phone表的Uri Uri uri = ContentUris.withAppendedId(phonesUri, id); Log.e("uri:",""+uri); //将信息放入容器中 ContentValues contentValues = new ContentValues(); //是否收藏,0不收藏,1为收藏 contentValues.put(People.STARRED, 0); contentValues.put(contacts_lable[2], getPhoneNum); //修改表中的数据 getContentResolver().update(uri, contentValues, null, null); //根据联系人的姓名查询出此联系人在People表中的数据 Cursor cusor = getContentResolver().query(peopleUri , contacts_lable , contacts_lable[1] + "=?" , new String[] { peopleName } , contacts_lable[1]+ " ASC"); cusor.moveToFirst();
//得到联系人在此表中的Uri
Uri uri2 = Uri.withAppendedPath(peopleUri, cusor.getString(cusor.getColumnIndex(contacts_lable[0])));
Log.e("uri2:",""+uri2);
ContentValues values = new ContentValues();
//是否收藏,0不收藏,1为收藏
values.put(People.STARRED, 0);
values.put(contacts_lable[1], getPeopleName);
//修改表中的数据