Hi,

I want to create/restore MMS to my device. Firstly I made backup of
MMS, which I have done quiet successfully. Now, I have the data of my
MMS. For simplicity, we assume that the MMS was having subject and
body only and no attachments. Lets say I delete my MMS and now I want
to restore it from the data that I have. e.g. I got following data
from different tables, while taking backup:

-> I query on ("content://mms/") and get the following data
    "_id" , "thread_id" , "date" , "read" , "sub"

-> Then I query on ("content://mms/" + ID + "/addr") and get the
following data
    "_id" , "msg_id" , "contact_id" , "type"  , "charset" , "address"

-> Then I query on ("content://mms/" + ID + "/part") and get the data
against all the columns of the Part table just   like "addr".


Now, when I insert back this data, I get the returned uri's which
shows that the new rows are made in DB and in respective tables. And
again upon reading the MMS DB, I see the newly added MMS and its data
but I can't see the MMS in my Android Messaging Application. Am I
missing some table to enter some data in it or am I missing something
else. Well I think it is a small problem because I can see the newly
added MMS Data in DB as exactly the same way it was before taking
backup.

------------------------------------------------------------------------------------
Here is the sample code that I am using:
------------------------------------------------------------------------------------

//The values below are the same (except date and subject) that I
retrieved from the MMS while backup and now I //am using these same
values for creating a new MMS. Please read comments against the values
for details.

                ContentResolver cr =
getApplicationContext().getContentResolver();
                ContentValues cv = new ContentValues();
                cv.put("thread_id", "1");  // This was the thread ID of the
reference MMS
                cv.put("date", "1307599944"); // Changed it because I am not
restoring the previous MMS. I am just //creating a new different MMS.
                cv.put("read", "1");
                cv.put("sub", "Hello Subject 2"); // Changed it because I am not
restoring the previous MMS. I am just //creating a new different MMS.
                Uri temp_mms = cr.insert(Uri.parse("content://mms/outbox"), 
cv);                //
I am using outbox because //of emulator.
                String str_uri = temp_mms.toString();
                // Getting the ID of newly added MMS
                String newID = str_uri.substring(("content://
mms/").length()).toString();

                // --------------------------ADDR Table
                ContentResolver cr_addr =
getApplicationContext().getContentResolver();
                ContentValues cv_addr1 = new ContentValues();
                cv_addr1.put("msg_id", newID);  // The new ID that we just got
                cv_addr1.put("contact_id", "null");
                cv_addr1.put("address", "insert-address-token"); // got this 
value
while backup, so putting it as well
                cv_addr1.put("type", "137");
                cv_addr1.put("charset", "106");
                Uri temp_mms_addr1 = cr.insert(Uri.parse("content://mms/"+ 
newID +"/
addr"), cv_addr1);

                ContentValues cv_addr2 = new ContentValues();
                cv_addr2.put("msg_id", newID);
                cv_addr2.put("contact_id", "null");
                cv_addr2.put("address", "1122");
                cv_addr2.put("type", "151");
                cv_addr2.put("charset", "106");
                Uri temp_mms_addr2 = cr.insert(Uri.parse("content://mms/"+ 
newID +"/
addr"), cv_addr2);

                // ------------------------------PART Table
                ContentValues cv_part1 = new ContentValues();
                cv_part1.put("mid", newID); // The new ID that we just got
                cv_part1.put("seq", "-1");
                cv_part1.put("ct", "application/smil");
                cv_part1.put("cid", "<smil>");
                cv_part1.put("cl", "smil.xml");
                cv_part1.put("text", "<smil><head><layout><root-layout 
width=\"320px
\" height=\"480px\"/><region id=\"Text\" left=\"0\" top=\"320\" width=
\"320px\" height=\"160px\" fit=\"meet\"/></layout></head><body><par
dur=\"5000ms\"><text src=\"text_0.txt\" region=\"Text\"/></par></
body></smil>");
                Uri temp_mms_part1 = cr.insert(Uri.parse("content://mms/"+ 
newID +"/
part"), cv_part1);

                ContentValues cv_part2 = new ContentValues();
                cv_part2.put("mid", newID); // The new ID that we just got
                cv_part2.put("seq", "0");
                cv_part2.put("ct", "text/plain");
                cv_part2.put("chset", "106");
                cv_part2.put("cid", "<text_0>"); // I kept the body same for 
new MMS
as well, not sure about it
                cv_part2.put("cl", "text_0.txt"); // I kept the body same for 
new
MMS as well, not sure about it
                cv_part2.put("text", "This is the body"); // I kept the body 
same
for new MMS as well, not sure about it
                Uri temp_mms_part2 = cr.insert(Uri.parse("content://mms/"+ 
newID +"/
part"), cv_part2);

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to