我想插入一个彩信到发送的数据库,但唉,我一直无法在原生android应用程序中查看它。插入发送彩信到发送框
我插入代码:
ContentValues values = new ContentValues();
values.put("thread_id", thread_id);
values.put("date", time);
values.put("read", true); //read status
values.put("sub", text); //mms subject
values.put("msg_box", 2); //message box. in this case outbox
Uri mmsUri = context.getContentResolver().
insert(Uri.parse("content://mms"), values);
Log.v("MMSProjectActivity", "Message saved at: " + mmsUri);
ContentValues mmsPartValue = new ContentValues();
mmsPartValue.put("ct", "image/jpeg"); //mime; for example image/jpeg
Uri picUri = picUris.get(0);
String [] fileNameSplit = picUri.toString().split("/");
String fileName = fileNameSplit[fileNameSplit.length-1] + ".jpg";
String messageId = mmsUri.getLastPathSegment().trim(); //id of MMS at content://mms
Uri partUri = Uri.parse("content://mms/" + messageId + "/part");
Uri mmsPartUri = context.getContentResolver().insert(partUri, mmsPartValue);
OutputStream os;
InputStream is;
try
{
os = context.getContentResolver().openOutputStream(mmsPartUri);
is = context.getContentResolver().openInputStream(picUris.get(0));
byte[] buffer = new byte[256];
for (int len = 0; (len = is.read(buffer)) != -1;) {
os.write(buffer, 0, len);
}
} catch (FileNotFoundException e)
{
Log.v("MMSProjectActivity", "MMS not saved FileNotFoundException");
e.printStackTrace();
} catch (IOException e)
{
Log.v("MMSProjectActivity", "MMS not saved IOException");
e.printStackTrace();
}
Log.v("MMSProjectActivity", "MMS part value saved at: " + mmsPartUri);
任何人有任何想法,我究竟做错了什么?
一些错误日志将是有益的:) – Tancho 2012-07-26 16:37:07
没有错误日志显示... – zwebie 2012-07-26 16:40:14
Interesting.can您确认该数据库拥有所有插入的行。我的意思是你能否确认你的记录已被保存?插入后是否验证过? 看看:http://gitorious.org/0xdroid/packages_providers_telephonyprovider/blobs/7236c3ad7ff01dd5ece14a2cabbf5ce3a570d793/src/com/android/providers/telephony/MmsProvider.java这是MMS应用程序如何查询MMS内容..你填写所有的领域?你是否在保存pdu字段等? 还可以看一下Google的邮件发件人:http://hi-android.info/src/com/android/mms/transaction/MmsMessageSender.java.html – Tancho 2012-07-26 22:58:16