android手机通讯录备份还原代码

上传者: xiaoxiao108 | 上传时间: 2019-12-21 22:02:14 | 文件大小: 48KB | 文件类型: zip
http://blog.csdn.net/xiaoxiao108/article/details/6901964 最近想写段android程序玩玩。 开发环境 eclipse ,android2.2 开发环境搭建 1.先安装jdk 2.下载安装eclipse 3.下载安装android sdk 4.安装eclipse插件 adt 5.配置 Window > Preferences 中的android sdk路径 6.创建 AVD 实现方法很简单 1.把通讯录中的联系人,电话号码保存到txt文件中完成备份。 2.读取txt文件,导入到通讯录完成还原。 具体代码 1.添加 通讯录读写权限,存储卡写权限 2.写文件代码 File saveFile=new File("/sdcard/test.txt"); FileOutputStream outStream; try { outStream = new FileOutputStream(saveFile); outStream.write(str.getBytes()); outStream.close(); } catch (Exception e) { setTitle(e.toString()); } 3.取通讯录联系人 str=""; Cursor cur = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); if (cur.moveToFirst()) { int idColumn = cur.getColumnIndex(ContactsContract.Contacts._ID); int displayNameColumn = cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); do { String contactId = cur.getString(idColumn); String disPlayName = cur.getString(displayNameColumn); str+=disPlayName; int phoneCount = cur.getInt(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)); if(phoneCount>0){ Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID+ " = " + contactId, null, null); int i=0; String phoneNumber; if(phones.moveToFirst()){ do{ i++; phoneNumber= phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phon

文件下载

资源详情

[{"title":"( 25 个子文件 48KB ) android手机通讯录备份还原代码","children":[{"title":"test","children":[{"title":"bin","children":[{"title":"classes.dex <span style='color:#111;'> 6.77KB </span>","children":null,"spread":false},{"title":"xintai","children":[{"title":"zhu","children":[{"title":"TestActivity$1.class <span style='color:#111;'> 1.35KB </span>","children":null,"spread":false},{"title":"R$layout.class <span style='color:#111;'> 370B </span>","children":null,"spread":false},{"title":"R$id.class <span style='color:#111;'> 392B </span>","children":null,"spread":false},{"title":"R$drawable.class <span style='color:#111;'> 376B </span>","children":null,"spread":false},{"title":"TestActivity$2.class <span style='color:#111;'> 1.88KB </span>","children":null,"spread":false},{"title":"R$attr.class <span style='color:#111;'> 316B </span>","children":null,"spread":false},{"title":"R.class <span style='color:#111;'> 475B </span>","children":null,"spread":false},{"title":"R$string.class <span style='color:#111;'> 403B </span>","children":null,"spread":false},{"title":"TestActivity.class <span style='color:#111;'> 4.16KB </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"resources.ap_ <span style='color:#111;'> 10.54KB </span>","children":null,"spread":false},{"title":"TestActivity.apk <span style='color:#111;'> 16.19KB </span>","children":null,"spread":false}],"spread":true},{"title":"res","children":[{"title":"drawable-ldpi","children":[{"title":"icon.png <span style='color:#111;'> 1.68KB </span>","children":null,"spread":false}],"spread":true},{"title":"drawable-hdpi","children":[{"title":"icon.png <span style='color:#111;'> 4.05KB </span>","children":null,"spread":false}],"spread":true},{"title":"values","children":[{"title":"strings.xml <span style='color:#111;'> 167B </span>","children":null,"spread":false}],"spread":true},{"title":"drawable-mdpi","children":[{"title":"icon.png <span style='color:#111;'> 2.51KB </span>","children":null,"spread":false}],"spread":true},{"title":"layout","children":[{"title":"main.xml <span style='color:#111;'> 660B </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"assets","children":null,"spread":false},{"title":"default.properties <span style='color:#111;'> 362B </span>","children":null,"spread":false},{"title":"gen","children":[{"title":"xintai","children":[{"title":"zhu","children":[{"title":"R.java <span style='color:#111;'> 781B </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true},{"title":"proguard.cfg <span style='color:#111;'> 1.22KB </span>","children":null,"spread":false},{"title":".settings","children":[{"title":"org.eclipse.jdt.core.prefs <span style='color:#111;'> 208B </span>","children":null,"spread":false}],"spread":true},{"title":"src","children":[{"title":"xintai","children":[{"title":"zhu","children":[{"title":"TestActivity.java <span style='color:#111;'> 5.70KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true},{"title":".project <span style='color:#111;'> 840B </span>","children":null,"spread":false},{"title":".classpath <span style='color:#111;'> 280B </span>","children":null,"spread":false},{"title":"AndroidManifest.xml <span style='color:#111;'> 945B </span>","children":null,"spread":false}],"spread":false}],"spread":true}]

评论信息

  • IBM_Forever :
    比较简单 提醒大家 没必要花5分下载 网上搜索一下csdn上面的很多博客都比这个写的好 不过还是感谢博主共享资源
    2016-10-20
  • zzs233 :
    的确可以用,在网上找了好多天,头都大了,就这个可以用,我翻译成了c#
    2016-08-22
  • lxkd521 :
    不错的学习资料,还可以在上面多完善一些功能
    2016-06-15
  • schy15 :
    挺好用的,至少为我们提供了一个扩展的例子
    2015-07-12
  • Wenlong_luo :
    可以用。解决了很多麻烦
    2015-06-23

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明