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()就可以了。

  • 相关阅读:
    Sum of Medians
    MINSUB
    Girls Love 233
    How Many Answers Are Wrong
    Sorting It All Out
    Cube Stacking
    Boolean Expressions
    表达式求值
    #1301 : 筑地市场
    用seaborn对数据可视化
  • 原文地址:https://www.cnblogs.com/mstk/p/3659177.html
Copyright © 2011-2022 走看看