Search code examples
androidsmsinbox

android: push sms As recieved in inbox using getContentResolver


on sms received , i have saved that sms in my database now i want to move that sms into inbox

i used this code but it move it as sent by me please help me to move it as a received sms

ListViewLogItem lm = listArray.get(position);
                long datein = Long.parseLong(lm.getInboxTime());
                    Uri uri = Uri.parse("content://sms/");
                    ContentValues cv2 = new ContentValues();
                    cv2.put("address","+"+lm.getNumber());
                    cv2.put("date", datein);
                    cv2.put("read", 1);
                    cv2.put("type", 2);
                    cv2.put("body", lm.getSms());


                    getContentResolver().insert(Uri.parse("content://sms/inbox"), cv2);

Solution

  • Change:

    cv2.put("type", 2);
    

    To:

    cv2.put("type", 1);
    

    Because:

    public static final int MESSAGE_TYPE_INBOX = 1;
    public static final int MESSAGE_TYPE_SENT = 2;