Android 簡訊資料庫詳細總結分析簡訊 sms 檔案 /data/data/com.android.providers.telephony/databases/mmssms.db
這個資料庫有13張表,sms表存了簡訊資訊。
sms表的uri是
public static final Uri CONTENT_URI = Uri.parse("content://sms"); 表項含義,我猜的
strColumnName=_id strColumnValue=48 //短訊息序號
strColumnName=thread_id strColumnValue=16 //對話的序號(conversation)
strColumnName=address strColumnValue=+8613411884805 //寄件者地址,手機號
strColumnName=person strColumnValue=null //寄件者,返回一個數字就是連絡人清單裡的序號,陌生人為null
strColumnName=date strColumnValue=1256539465022 //日期 long型,想得到具體日期自己轉換吧!
strColumnName=protocol strColumnValue=0 //協議
strColumnName=read strColumnValue=1 //是否閱讀
strColumnName=status strColumnValue=-1 //狀態
strColumnName=type strColumnValue=1 //類型 1是接收到的,2是發出的
strColumnName=reply_path_present strColumnValue=0 //
strColumnName=subject strColumnValue=null //主題
strColumnName=body strColumnValue=您好 //短訊息內容
strColumnName=service_center strColumnValue=+8613800755500 //簡訊服務中心號碼編號,可以得知該簡訊是從哪裡發過來的
把源碼補上。
在frameworks/base/core/java/android/provider/Telephony.java
/** * The thread ID of the message * <P>Type: INTEGER</P> */ public static final String THREAD_ID = "thread_id"; /** * The address of the other party * <P>Type: TEXT</P> */ public static final String ADDRESS = "address"; /** * The person ID of the sender * <P>Type: INTEGER (long)</P> */ public static final String PERSON_ID = "person"; /** * The date the message was sent * <P>Type: INTEGER (long)</P> */ public static final String DATE = "date"; /** * The protocol identifier code * <P>Type: INTEGER</P> */ public static final String PROTOCOL = "protocol"; /** * Has the message been read * <P>Type: INTEGER (boolean)</P> */ public static final String READ = "read"; /** * The TP-Status value for the message, or -1 if no status has * been received */ public static final String STATUS = "status"; us 舉例: public static final int STATUS_NONE = -1; public static final int STATUS_COMPLETE = 0; public static final int STATUS_PENDING = 64; public static final int STATUS_FAILED = 128; /** * The type of the message * <P>Type: INTEGER</P> */ public static final String TYPE = "type"; 舉例 public static final int MESSAGE_TYPE_ALL = 0; public static final int MESSAGE_TYPE_INBOX = 1; public static final int MESSAGE_TYPE_SENT = 2; public static final int MESSAGE_TYPE_DRAFT = 3; public static final int MESSAGE_TYPE_OUTBOX = 4; public static final int MESSAGE_TYPE_FAILED = 5; // for failed outgoing messages public static final int MESSAGE_TYPE_QUEUED = 6; // for messages to send later /** * Whether the <code>TP-Reply-Path</code> bit was set on this message * <P>Type: BOOLEAN</P> */ public static final String REPLY_PATH_PRESENT = "reply_path_present"; /** * The subject of the message, if present * <P>Type: TEXT</P> */ public static final String SUBJECT = "subject"; /** * The body of the message * <P>Type: TEXT</P> */ public static final String BODY = "body"; /** * The service center (SC) through which to send the message, if present * <P>Type: TEXT</P> */ public static final String SERVICE_CENTER = "service_center"; 轉載自http://hi.baidu.com/tclc2009/blog/item/63ab71ecca46ab382cf53409.html