- 浏览: 138101 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
bi_bao:
lz好啊 我也在做彩信的备份还原工作.您的附件还原代码很有用, ...
彩信 -
suifeng0211:
如果想不调用系统彩信界面,直接从后台发送,就比较麻烦了。但确定 ...
彩信发送。 -
atmus:
横竖看不懂
彩信发送。 -
smartdongdong:
这么好的帖子才看到!
MMS/SMS 入口 , -
A_L_85:
在LauncherModel中final Cursor c = ...
Android2.1_Launcher2学习笔记
短信 sms
文件 /data/data/com.android.providers.telephony/databases/mmssms.db
这个数据库有13张表,sms表存了短信信息。
sms表的uri是
表项含义,我猜的
0 _id
1 thread_id 在短信界面里显示在第几组( 相同联系人的短信在同意行),英文名叫话题。
2 address 电话好吗
3 person ? 存在电话簿里的名字 。 可能吧
4 date 日期
5 protocol ?..
6 read ? 1- 已读 0-未读
7 status ?
8 type ? 2 我发送
9 reply_path_present ?
10 subject
11 body 短信内容
12 service_center ...
好没信息量。。。。
把源码补上。
在frameworks/base/core/java/android/provider/Telephony.java
彩信。
1、pdu表
mmssms.db库中的pdu表存储了彩信标题、彩信接收时间和彩信ID等信息,其中“_id”是主键,唯一标识了一个条彩信。
pdu 表源码
2、part表
mmssms.db库中的part表存储了彩信内容(文本、音乐、图象)的文件名(即上面将的app_parts下面的文件名)、文件类型信息。
其中“mid”对应着pdu表中的“_id”,“ct”是文件类型,“_data”是存储路径。
3 。 彩信文件读取
彩信附件文件的地址存储在mmssms.db的part表的_data字段,形如“/data/data/com.android.providers.telephony/app_parts/PART_1262693697763”,但在应用中读取彩信附件时,这个字段基本没什么用,因为不能直接读取这个文件。读取同样要通过ContentProvider,URI为“content://mms/part”,该URI就是对应着part表。可以使用下列代码段来读取文件:
String selection = new String("mid='" + key + "'");//这个key就是pdu里面的_id。
Cursor cur = getContentResolver().query(Uri.parse("content://mms/part"), null, selection, null, null);
if (cur.moveToFirst())
do {
int _partID = cur.getInt(cur.getColumnIndex("_id"));
String partID = String.valueOf(_partID);
Uri partURI = Uri.parse("content://mms/part/" + partID);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream is = null;
try {
is = getContentResolver().openInputStream(partURI);
byte[] buffer = new byte[256];
int len = is.read(buffer);
while (len >= 0)
{
baos.write(buffer, 0, len);
len = is.read(buffer);
}
} catch (IOException e) {
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
}
}
}
}
这里得到的baos,就是附件文件。
文件 /data/data/com.android.providers.telephony/databases/mmssms.db
这个数据库有13张表,sms表存了短信信息。
sms表的uri是
public static final Uri CONTENT_URI = Uri.parse("content://sms");
表项含义,我猜的
0 _id
1 thread_id 在短信界面里显示在第几组( 相同联系人的短信在同意行),英文名叫话题。
2 address 电话好吗
3 person ? 存在电话簿里的名字 。 可能吧
4 date 日期
5 protocol ?..
6 read ? 1- 已读 0-未读
7 status ?
8 type ? 2 我发送
9 reply_path_present ?
10 subject
11 body 短信内容
12 service_center ...
好没信息量。。。。
把源码补上。
在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"; // status 举例: 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"; // 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"; // 另外还有 /** * Has the message been locked? * <P>Type: INTEGER (boolean)</P> */ public static final String LOCKED = "locked"; /** * The id of the sender of the conversation, if present * <P>Type: INTEGER (reference to item in content://contacts/people)</P> */ public static final String PERSON = "person";
彩信。
1、pdu表
mmssms.db库中的pdu表存储了彩信标题、彩信接收时间和彩信ID等信息,其中“_id”是主键,唯一标识了一个条彩信。
pdu 表源码
/** * Base columns for tables that contain MMSs. */ public interface BaseMmsColumns extends BaseColumns { public static final int MESSAGE_BOX_ALL = 0; public static final int MESSAGE_BOX_INBOX = 1; public static final int MESSAGE_BOX_SENT = 2; public static final int MESSAGE_BOX_DRAFTS = 3; public static final int MESSAGE_BOX_OUTBOX = 4; /** * The date the message was sent. * <P>Type: INTEGER (long)</P> */ public static final String DATE = "date"; /** * The box which the message belong to, for example, MESSAGE_BOX_INBOX. * <P>Type: INTEGER</P> */ public static final String MESSAGE_BOX = "msg_box"; /** * Has the message been read. * <P>Type: INTEGER (boolean)</P> */ public static final String READ = "read"; /** * The Message-ID of the message. * <P>Type: TEXT</P> */ public static final String MESSAGE_ID = "m_id"; /** * The subject of the message, if present. * <P>Type: TEXT</P> */ public static final String SUBJECT = "sub"; /** * The character set of the subject, if present. * <P>Type: INTEGER</P> */ public static final String SUBJECT_CHARSET = "sub_cs"; /** * The Content-Type of the message. * <P>Type: TEXT</P> */ public static final String CONTENT_TYPE = "ct_t"; /** * The Content-Location of the message. * <P>Type: TEXT</P> */ public static final String CONTENT_LOCATION = "ct_l"; /** * The address of the sender. * <P>Type: TEXT</P> */ public static final String FROM = "from"; /** * The address of the recipients. * <P>Type: TEXT</P> */ public static final String TO = "to"; /** * The address of the cc. recipients. * <P>Type: TEXT</P> */ public static final String CC = "cc"; /** * The address of the bcc. recipients. * <P>Type: TEXT</P> */ public static final String BCC = "bcc"; /** * The expiry time of the message. * <P>Type: INTEGER</P> */ public static final String EXPIRY = "exp"; /** * The class of the message. * <P>Type: TEXT</P> */ public static final String MESSAGE_CLASS = "m_cls"; /** * The type of the message defined by MMS spec. * <P>Type: INTEGER</P> */ public static final String MESSAGE_TYPE = "m_type"; /** * The version of specification that this message conform. * <P>Type: INTEGER</P> */ public static final String MMS_VERSION = "v"; /** * The size of the message. * <P>Type: INTEGER</P> */ public static final String MESSAGE_SIZE = "m_size"; /** * The priority of the message. * <P>Type: TEXT</P> */ public static final String PRIORITY = "pri"; /** * The read-report of the message. * <P>Type: TEXT</P> */ public static final String READ_REPORT = "rr"; /** * Whether the report is allowed. * <P>Type: TEXT</P> */ public static final String REPORT_ALLOWED = "rpt_a"; /** * The response-status of the message. * <P>Type: INTEGER</P> */ public static final String RESPONSE_STATUS = "resp_st"; /** * The status of the message. * <P>Type: INTEGER</P> */ public static final String STATUS = "st"; /** * The transaction-id of the message. * <P>Type: TEXT</P> */ public static final String TRANSACTION_ID = "tr_id"; /** * The retrieve-status of the message. * <P>Type: INTEGER</P> */ public static final String RETRIEVE_STATUS = "retr_st"; /** * The retrieve-text of the message. * <P>Type: TEXT</P> */ public static final String RETRIEVE_TEXT = "retr_txt"; /** * The character set of the retrieve-text. * <P>Type: TEXT</P> */ public static final String RETRIEVE_TEXT_CHARSET = "retr_txt_cs"; /** * The read-status of the message. * <P>Type: INTEGER</P> */ public static final String READ_STATUS = "read_status"; /** * The content-class of the message. * <P>Type: INTEGER</P> */ public static final String CONTENT_CLASS = "ct_cls"; /** * The delivery-report of the message. * <P>Type: INTEGER</P> */ public static final String DELIVERY_REPORT = "d_rpt"; /** * The delivery-time-token of the message. * <P>Type: INTEGER</P> */ public static final String DELIVERY_TIME_TOKEN = "d_tm_tok"; /** * The delivery-time of the message. * <P>Type: INTEGER</P> */ public static final String DELIVERY_TIME = "d_tm"; /** * The response-text of the message. * <P>Type: TEXT</P> */ public static final String RESPONSE_TEXT = "resp_txt"; /** * The sender-visibility of the message. * <P>Type: TEXT</P> */ public static final String SENDER_VISIBILITY = "s_vis"; /** * The reply-charging of the message. * <P>Type: INTEGER</P> */ public static final String REPLY_CHARGING = "r_chg"; /** * The reply-charging-deadline-token of the message. * <P>Type: INTEGER</P> */ public static final String REPLY_CHARGING_DEADLINE_TOKEN = "r_chg_dl_tok"; /** * The reply-charging-deadline of the message. * <P>Type: INTEGER</P> */ public static final String REPLY_CHARGING_DEADLINE = "r_chg_dl"; /** * The reply-charging-id of the message. * <P>Type: TEXT</P> */ public static final String REPLY_CHARGING_ID = "r_chg_id"; /** * The reply-charging-size of the message. * <P>Type: INTEGER</P> */ public static final String REPLY_CHARGING_SIZE = "r_chg_sz"; /** * The previously-sent-by of the message. * <P>Type: TEXT</P> */ public static final String PREVIOUSLY_SENT_BY = "p_s_by"; /** * The previously-sent-date of the message. * <P>Type: INTEGER</P> */ public static final String PREVIOUSLY_SENT_DATE = "p_s_d"; /** * The store of the message. * <P>Type: TEXT</P> */ public static final String STORE = "store"; /** * The mm-state of the message. * <P>Type: INTEGER</P> */ public static final String MM_STATE = "mm_st"; /** * The mm-flags-token of the message. * <P>Type: INTEGER</P> */ public static final String MM_FLAGS_TOKEN = "mm_flg_tok"; /** * The mm-flags of the message. * <P>Type: TEXT</P> */ public static final String MM_FLAGS = "mm_flg"; /** * The store-status of the message. * <P>Type: TEXT</P> */ public static final String STORE_STATUS = "store_st"; /** * The store-status-text of the message. * <P>Type: TEXT</P> */ public static final String STORE_STATUS_TEXT = "store_st_txt"; /** * The stored of the message. * <P>Type: TEXT</P> */ public static final String STORED = "stored"; /** * The totals of the message. * <P>Type: TEXT</P> */ public static final String TOTALS = "totals"; /** * The mbox-totals of the message. * <P>Type: TEXT</P> */ public static final String MBOX_TOTALS = "mb_t"; /** * The mbox-totals-token of the message. * <P>Type: INTEGER</P> */ public static final String MBOX_TOTALS_TOKEN = "mb_t_tok"; /** * The quotas of the message. * <P>Type: TEXT</P> */ public static final String QUOTAS = "qt"; /** * The mbox-quotas of the message. * <P>Type: TEXT</P> */ public static final String MBOX_QUOTAS = "mb_qt"; /** * The mbox-quotas-token of the message. * <P>Type: INTEGER</P> */ public static final String MBOX_QUOTAS_TOKEN = "mb_qt_tok"; /** * The message-count of the message. * <P>Type: INTEGER</P> */ public static final String MESSAGE_COUNT = "m_cnt"; /** * The start of the message. * <P>Type: INTEGER</P> */ public static final String START = "start"; /** * The distribution-indicator of the message. * <P>Type: TEXT</P> */ public static final String DISTRIBUTION_INDICATOR = "d_ind"; /** * The element-descriptor of the message. * <P>Type: TEXT</P> */ public static final String ELEMENT_DESCRIPTOR = "e_des"; /** * The limit of the message. * <P>Type: INTEGER</P> */ public static final String LIMIT = "limit"; /** * The recommended-retrieval-mode of the message. * <P>Type: INTEGER</P> */ public static final String RECOMMENDED_RETRIEVAL_MODE = "r_r_mod"; /** * The recommended-retrieval-mode-text of the message. * <P>Type: TEXT</P> */ public static final String RECOMMENDED_RETRIEVAL_MODE_TEXT = "r_r_mod_txt"; /** * The status-text of the message. * <P>Type: TEXT</P> */ public static final String STATUS_TEXT = "st_txt"; /** * The applic-id of the message. * <P>Type: TEXT</P> */ public static final String APPLIC_ID = "apl_id"; /** * The reply-applic-id of the message. * <P>Type: TEXT</P> */ public static final String REPLY_APPLIC_ID = "r_apl_id"; /** * The aux-applic-id of the message. * <P>Type: TEXT</P> */ public static final String AUX_APPLIC_ID = "aux_apl_id"; /** * The drm-content of the message. * <P>Type: TEXT</P> */ public static final String DRM_CONTENT = "drm_c"; /** * The adaptation-allowed of the message. * <P>Type: TEXT</P> */ public static final String ADAPTATION_ALLOWED = "adp_a"; /** * The replace-id of the message. * <P>Type: TEXT</P> */ public static final String REPLACE_ID = "repl_id"; /** * The cancel-id of the message. * <P>Type: TEXT</P> */ public static final String CANCEL_ID = "cl_id"; /** * The cancel-status of the message. * <P>Type: INTEGER</P> */ public static final String CANCEL_STATUS = "cl_st"; /** * The thread ID of the message * <P>Type: INTEGER</P> */ public static final String THREAD_ID = "thread_id"; /** * Has the message been locked? * <P>Type: INTEGER (boolean)</P> */ public static final String LOCKED = "locked"; }
2、part表
mmssms.db库中的part表存储了彩信内容(文本、音乐、图象)的文件名(即上面将的app_parts下面的文件名)、文件类型信息。
其中“mid”对应着pdu表中的“_id”,“ct”是文件类型,“_data”是存储路径。
3 。 彩信文件读取
彩信附件文件的地址存储在mmssms.db的part表的_data字段,形如“/data/data/com.android.providers.telephony/app_parts/PART_1262693697763”,但在应用中读取彩信附件时,这个字段基本没什么用,因为不能直接读取这个文件。读取同样要通过ContentProvider,URI为“content://mms/part”,该URI就是对应着part表。可以使用下列代码段来读取文件:
String selection = new String("mid='" + key + "'");//这个key就是pdu里面的_id。
Cursor cur = getContentResolver().query(Uri.parse("content://mms/part"), null, selection, null, null);
if (cur.moveToFirst())
do {
int _partID = cur.getInt(cur.getColumnIndex("_id"));
String partID = String.valueOf(_partID);
Uri partURI = Uri.parse("content://mms/part/" + partID);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream is = null;
try {
is = getContentResolver().openInputStream(partURI);
byte[] buffer = new byte[256];
int len = is.read(buffer);
while (len >= 0)
{
baos.write(buffer, 0, len);
len = is.read(buffer);
}
} catch (IOException e) {
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
}
}
}
}
这里得到的baos,就是附件文件。
相关推荐
本文将深入探讨如何在Android中插入彩信到其数据库,以及如何新建和导入彩信的相关知识点。 首先,理解Android中的MMS机制是至关重要的。Android系统通过ContentProvider接口与多媒体消息数据库交互,这个接口使得...
提供的`InsertMmsDemo`文件可能包含了一个具体的实现例子,通过分析这个示例代码,你可以更清楚地了解如何操作短信和彩信数据库。 综上所述,向Android的SQLite数据库插入短信和彩信数据涉及对ContentProvider、...
在Android操作系统中,通话、通讯录、短信和彩信是移动设备的核心功能,它们构成了用户与外界交流的主要渠道。下面将详细阐述这些知识点,并提供一个简单的Contact_Demo应用实例。 **1. 通讯录(Contacts)** ...
本资源“安卓短信彩信相关-android模拟短信插入和接收.rar”提供了一些关于如何在Android环境中模拟短信的插入与接收的代码示例。以下是对这些知识点的详细说明: 1. **短信API**: 安卓系统提供了`SmsManager`类...
在Android操作系统中,短信、彩信和联系人管理是核心功能之一,对于开发者来说,深入理解这些组件的源码能够帮助他们提升应用开发的技术水平。Android 4.2版本是Google发布的一个重要的移动操作系统更新,引入了许多...
在这个"安卓短信彩信相关-广播监听短信并获取短信内容.rar"的压缩包中,我们可以看到开发者提供了关于如何监听和获取短信内容的示例代码。下面将详细解释相关的核心概念和技术。 首先,短信监听是通过实现Android...
- 在处理彩信时,需要注意权限问题,特别是访问短信和彩信数据库的权限。 - 由于彩信可能包含多种类型的数据,因此在处理彩信时需要根据不同类型的数据采用不同的处理方式。 - Android系统版本的不同可能会导致API的...
这个压缩包“安卓短信彩信相关相关-短信黑名单简单实现代码.rar”似乎包含了一些用于实现短信黑名单功能的源代码。短信黑名单功能允许用户阻止特定号码发送的短信,以避免骚扰或不必要的通信。以下是对这个主题的...
这个实体将被用来构造`ContentValues`,然后插入到系统的彩信数据库中。 4. **构建事务**: 使用`ContentResolver`来开始一个数据库事务,插入彩信消息到`mmssms`表中。在API 19及以上,可能需要使用`Uri`的`...
短彩信数据表结构是数据库设计的一部分,用于存储和管理短信和彩信的相关信息。以下是对Android MMS模块数据存储的详细解释: 首先,MMS模块包含了17张数据表,每张表都有特定的用途。例如,`addr`表存储地址信息,...
这个压缩包文件“安卓短信彩信相关相关-一个短信应用源码.rar”包含了与Android平台上短信和彩信处理相关的源代码。源代码是开发者用来构建应用程序的基础,它提供了深入理解软件工作原理的机会。在这个特定的案例中...
总的来说,理解和解决安卓短信彩信应用的运行问题,需要深入理解安卓系统的工作原理,熟练掌握Java或Kotlin编程,以及熟悉安卓开发工具的使用。通过上述分析和建议,你应该能够逐步排查并修复“马上有短信”应用遇到...
在Android平台上,短信和彩信是用户日常通讯的重要组成部分。为了提供更好的用户体验或者进行数据分析,开发者有时需要对用户的短信和彩信进行备份。本实例源码包正专注于这个主题,提供了一套完整的解决方案来实现...
7. **学习资源**:除了这个练习例子,还有很多官方文档和社区资源可以帮助学习短信彩信编程,比如Android Developer官网,Stack Overflow,以及各种编程论坛。 8. **安全考虑**:处理短信和彩信时,应考虑隐私和...
综上所述,这个“android 浏览普通彩信列表demo”涉及到的关键知识点包括:布局设计(xml文件解析)、`ListView`与适配器的使用、数据库查询、多媒体文件处理、广播接收器的注册和使用,以及性能优化。通过理解和...
在Android系统中,短信和彩信的收发是通信功能的核心部分。本资源专注于实现对短信的拦截和显示,以及彩信的拦截和保存。同时,它还包含了短信的发送功能,确保用户能够全面地控制和管理自己的消息交互。下面我们将...
此压缩包"安卓短信彩信相关相关-从5.0系统剥离出的彩信部分收发源码.rar"包含了Android 5.0(Lollipop)系统中关于短信和彩信收发的原始代码片段。这些源码对于深入理解Android系统如何处理彩信,以及开发者如何...
这个压缩包文件"安卓短信彩信相关相关-发送短信长短信群发短信.rar"包含了一系列与短信和彩信发送相关的代码示例,虽然可能无法逐一验证其全部功能,但它们可以作为开发者学习和参考的资源。下面我们将深入探讨这些...
这个压缩包文件“安卓短信彩信相关相关-该DEMO主要实现类似短信倒计时显示.zip”是一个关于Android平台上的应用程序示例,专注于短信和彩信的特定功能,特别是倒计时显示。在这个DEMO中,开发者可能创建了一个界面,...
这三个表格共同构成了Android短信系统的数据结构,便于高效地检索、管理和操作短信数据。通过查询和分析这些表格,开发者可以实现各种功能,如统计未读短信、查找特定会话、显示联系人信息以及处理发送失败的情况等...