在 Android 收件箱中保存/创建彩信
我正在开发一个应用程序,需要能够在收件箱或发送文件夹中保存/创建新的彩信,但我不知道方法。
我尝试了以下代码,但它给了我异常:异常
ContentValues values = new ContentValues();
values.put("address", "xxxxxxxxxxx");
values.put("body", "body 3");
values.put("read", "0");
getContentResolver().insert(Uri.parse("content://mms/inbox"), values);
是:
ERROR/Database(118): Error inserting read=0 body=body 3 msg_box=1 date=1306153444 address=xxxxxxxxxxx
ERROR/Database(118): android.database.sqlite.SQLiteException: table pdu has no column named body: , while compiling: INSERT INTO pdu(read, body, msg_box, date, address) VALUES(?, ?, ?, ?, ?);
ERROR/Database(118): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
ERROR/Database(118): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
ERROR/Database(118): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
ERROR/Database(118): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
ERROR/Database(118): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:36)
ERROR/Database(118): at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1145)
ERROR/Database(118): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1536)
ERROR/Database(118): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1410)
ERROR/Database(118): at com.android.providers.telephony.MmsProvider.insert(MmsProvider.java:347)
ERROR/Database(118): at android.content.ContentProvider$Transport.insert(ContentProvider.java:174)
ERROR/Database(118): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:146)
ERROR/Database(118): at android.os.Binder.execTransact(Binder.java:288)
ERROR/Database(118): at dalvik.system.NativeStart.run(Native Method)
ERROR/MmsProvider(118): MmsProvider.insert: failed! read=0 body=body 3 msg_box=1 date=1306153444 address=xxxxxxxxxxx
UDPATE:通过删除行删除异常:values.put(“body”,“body 3”) 但我在消息中看不到任何彩信。
I am working on an Application which needs to be able to Save/Create a new MMS in inbox or Sent folders but I cant figure out the way.
I tried the following code but it gave me exception:
ContentValues values = new ContentValues();
values.put("address", "xxxxxxxxxxx");
values.put("body", "body 3");
values.put("read", "0");
getContentResolver().insert(Uri.parse("content://mms/inbox"), values);
And the Exception is:
ERROR/Database(118): Error inserting read=0 body=body 3 msg_box=1 date=1306153444 address=xxxxxxxxxxx
ERROR/Database(118): android.database.sqlite.SQLiteException: table pdu has no column named body: , while compiling: INSERT INTO pdu(read, body, msg_box, date, address) VALUES(?, ?, ?, ?, ?);
ERROR/Database(118): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
ERROR/Database(118): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
ERROR/Database(118): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
ERROR/Database(118): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
ERROR/Database(118): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:36)
ERROR/Database(118): at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1145)
ERROR/Database(118): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1536)
ERROR/Database(118): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1410)
ERROR/Database(118): at com.android.providers.telephony.MmsProvider.insert(MmsProvider.java:347)
ERROR/Database(118): at android.content.ContentProvider$Transport.insert(ContentProvider.java:174)
ERROR/Database(118): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:146)
ERROR/Database(118): at android.os.Binder.execTransact(Binder.java:288)
ERROR/Database(118): at dalvik.system.NativeStart.run(Native Method)
ERROR/MmsProvider(118): MmsProvider.insert: failed! read=0 body=body 3 msg_box=1 date=1306153444 address=xxxxxxxxxxx
UDPATE: Exception removed by removing the line: values.put("body","body 3")
But I can't see any mms in messages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也遇到了同样的问题。但是我成功创建并恢复了彩信。它基本上是数据库的反向操作。我希望你能从数据库中得到一条彩信,对吗?您只需将适当的值放回数据库表中即可。您可以在 mmssms.db 中获取有关数据库表的信息。一旦理解了mmssms.db,插入彩信就变得非常容易。
I was having the same problem. However I successfully created and restored an MMS. It's basically reverse manipulation of database. I hope you can get an MMS from the database, right? You just need to put back appropriate values in database tables. You can get information about database tables in mmssms.db. Once you understand the mmssms.db, it's very easy to insert an MMS.
彩信正文存储在
content://mms/part/
中。请参阅此代码了解如何从中读取内容,但请记住所有这些都没有记录,不受支持,并且可能会更改,恕不另行通知。The body of the MMS is stored in
content://mms/part/
. See this code for how to read from it, but remember that all of this is undocumented, unsupported and likely to change without notice.首先,当您创建一个要用作彩信屏幕的屏幕时。
然后,当您完成后,请尝试使用代码将彩信发送给您想要的其他人。
在这里,您首先在项目中声明一个 btn_email 按钮。
btn_email = (按钮)findViewById(R.id.btn_email);
然后在这个按钮上编写onclick事件,这将有助于将彩信发送给其他人。
发送彩信代码:
btn_email.setOnClickListener(new View.OnClickListener()
{
@覆盖
公共无效onClick(查看v){
// TODO 自动生成的方法存根
System.out.println("刚刚按下电子邮件按钮..");
这是将从您的 SD 卡路径发送彩信给其他人的代码。
此代码使用意图代码,是 Android 默认电子邮件发送屏幕将使用的。
通过这种方式,您可以将彩信发送给其他人。
现在要保存您发送给其他人的颗粒彩信,当您开发您创建的屏幕时,您只需捕获整个屏幕...并保存在 SD 卡中,例如...
例如:
btn_save = (Button)findViewById( R.id.btn_save);
受保护无效 saveImageToSD() {
// TODO 自动生成的方法存根
上面的代码将保存您发送的屏幕,然后您只需从 SD 卡特定路径名访问或获取该图像
first as you create one screen which you wants to use as the mms screen.
then after as you completed to make it try this under code to send that mms to other person to whom you want.
here you first declare one btn_email button on your project.
btn_email = (Button)findViewById(R.id.btn_email);
then write the onclickevent on this button which will able to help to send the mms to other person.
send mms code:
btn_email.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
System.out.println("the email button is just pressed..");
here is the code which will send the mms to other person form your sdcard path.
this code using the intent code is the android default email sending screen will use.
by this way you are able to send the mms to other person.
now to save the that particulate mms which you have send that other person , as you develop that screen which you have created you just capture that whole screen...and save in sd card like..
e.g:
btn_save = (Button)findViewById(R.id.btn_save);
protected void saveImageToSD() {
// TODO Auto-generated method stub
this above code will save that of screen which you have send then simply you just access or fetch that image from your sdcard specific path name