title: Inserting Sent MMS into sent box
body: <p>I'm trying to insert a MMS into the sent database but alas I haven't been able to view it in the native android application.</p>
  
  <p>my insertion code:</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>anybody have any idea what am I doing wrong?</p>