zoukankan      html  css  js  c++  java
  • 将已发送的短信写入短信数据库

    把短信发送出去以后,一般要把已发送的短信写入短信数据库。短信数据库有多个Uri,其中已发送的Uri是content://sms/sent。

    	// 把短信写入数据库
    	public void writeMsg(){
    		
    		try{
    			ContentValues values = new ContentValues();
    			// 发送时间
    			values.put("date", System.currentTimeMillis());
    			// 阅读状态            
    			values.put("read", 0);
    			// 类型:1为收,2为发           
    			values.put("type", 2);
    			// 发送号码            
    			values.put("address",smsWidget.str_number);
    			// 发送内容          
    			values.put("body", content);
    			// 插入短信库  
    			getContentResolver().insert(Uri.parse("content://sms/sent"), values);			
    		}catch (Exception e) {  
                		Log.d("Exception", e.getMessage()); 
    		}
    		
    	}
    

    定义一个新的ContentValues,将短信的相关数据put进去,然后getContentResolver().insert()就可以了。

  • 相关阅读:
    SQL第一讲
    CSS3补充内容
    EXCEL数据导入SQL表的方法
    jq第四讲+实例
    jq第三讲
    jq第二讲
    安卓、苹果日历同步
    安卓、苹果手机备忘录同步
    服务器、客户端双认证
    今天我的博客正式开张了!
  • 原文地址:https://www.cnblogs.com/mstk/p/3659177.html
Copyright © 2011-2022 走看看