把短信发送出去以后,一般要把已发送的短信写入短信数据库。短信数据库有多个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()就可以了。

相关文章:

  • 2022-03-02
  • 2021-05-12
  • 2021-10-19
  • 2022-12-23
  • 2021-11-11
  • 2021-12-04
  • 2021-11-27
猜你喜欢
  • 2021-12-27
  • 2021-06-21
  • 2021-09-26
相关资源
相似解决方案