[Android]逸雨清风 安卓资料导出备份 APP

逸雨清风 安卓资料导出备份 v1.0

该软件支持导入导出手机通讯录与短信,可以通过导出进行备份,还可以直接阅读导出信息。导出文件存储在手机和SD卡里双重保险。

下一版本设计:

1、添加备忘录导入导出

2、优化导入导出时间

3、添加更多导出选项

4、支持网络化传送导出文件,互相导入

下载地址:      爱问共享:http://ishare.iask.sina.com.cn/f/63443832.html

                       CSDN:http://download.csdn.net/detail/xyydyyqf/6514665

部分代码:

导出通讯录

public void GetTongXun() throws IOException
    {  
    	ContentResolver resolver = this.getContentResolver();  
        Uri uri = Uri.parse("content://com.android.contacts/contacts");  
        Cursor cursor = resolver.query(uri, new String[]{Data._ID}, null, null, null);  
        
        File file = CreatFile(dir+"通讯录.txt");
    	FileOutputStream outputStream = new FileOutputStream(file);
    	FileOutputStream fos = null;
    	fos = openFileOutput("通讯录.txt",Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
    	
        while(cursor.moveToNext())
        {  
            StringBuilder buf = new StringBuilder();  
            int id = cursor.getInt(0);//获得id并且在data中寻找数据   
            uri = Uri.parse("content://com.android.contacts/contacts/"+id+"/data"); //如果要获得data表中某个id对应的数据,则URI为content://com.android.contacts/contacts/#/data  
            
            Cursor cursor2 = resolver.query(uri, new String[]{Data.DATA1,Data.MIMETYPE,Data.DATA10}, null,null, null);  //data1存储各个记录的总数据,mimetype存放记录的类型,如电话、email等
            String phone = null;
            while(cursor2.moveToNext())
            { 
                String data = cursor2.getString(cursor2.getColumnIndex("data1"));
                if(cursor2.getString(cursor2.getColumnIndex("mimetype")).equals("vnd.android.cursor.item/name") && cursor2.getString(cursor2.getColumnIndex("data10")).equals("2") ){     //如果是名字   
                    buf.append(data);
                    if (phone != null) buf.append(phone);
                }  
                else if(cursor2.getString(cursor2.getColumnIndex("mimetype")).equals("vnd.android.cursor.item/phone_v2")){//如果是电话
                	phone = new String(" "+data+"\n");
                }   
            }  
            String str = buf.toString();                 
            try {
            	outputStream.write(str.getBytes());
            	fos.write(str.getBytes());
			} catch (IOException ex) {}
        }  
        try {
        	outputStream.close();
        	fos.close();
		} catch (IOException ex) {}
        new AlertDialog.Builder(this).setMessage("成功导出通讯录!").show();
    }  

导出短信


public void OutDuanxin() throws IOException
	{
		Uri uri = Uri.parse("content://sms/");  
        smsContent sc = new smsContent(this,uri);  
        List<smsInfo> infos = sc.getSmsInfo();
        List<smsInfo> realinfos = sc.getRealSmsInfo();
       
        File file = CreatFile(dir+"短信.txt");
    	FileOutputStream outputStream = new FileOutputStream(file);
    	FileOutputStream fos = null;
    	fos = openFileOutput("短信.txt",Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
    	
    	File realfileFile = CreatFile(dir+"duanxin.yyqf");
    	FileOutputStream realoutputStream = new FileOutputStream(realfileFile);
    	FileOutputStream realfos = null;
    	realfos = openFileOutput("duanxin.yyqf",Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
    	
    	String string = new String();
    	String realString = new String();
    	for (int i=0;i<infos.size();i++)
    	{
    		string+=infos.get(i).getName();
    		string+="\n号码:"+infos.get(i).getPhoneNumber();
    		string+="\n日期:"+infos.get(i).getDate();
    		string+="\n消息:"+infos.get(i).getSmsbody();
    		string+="\n====================================\n";
    		
    		realString+=realinfos.get(i).getPhoneNumber()+"\n";
    		realString+=realinfos.get(i).getSmsbody()+"\n";
    		realString+= ".!@#$%^&*().[].yyqf\n" + realinfos.get(i).getDate()+"\n";
    		realString+=realinfos.get(i).getType()+"\n";
    	}
        try {
        	fos.write(string.getBytes());
        	outputStream.write(string.getBytes());
        	realfos.write(realString.getBytes());
        	realoutputStream.write(realString.getBytes());
		} catch (Exception e) {}
        try {
        	outputStream.close();
        	fos.close();
        	realfos.close();
        	realoutputStream.close();
		} catch (IOException ex) {}
        new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_info).setMessage("成功导出短信!").show();
	}


 /*

******逸雨清风 出品

******http://blog.csdn.net/xyydyyqf

******YYQF © 2013.11

*/


  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

逸雨清风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值