I have the following code which works fine in older versions of Android, but not on 4.4.2. No errors occur and nothing in logcat, but the messages do not show up in the default SMS app in the emulator. So my question is why it doesn't work on 4.4.2 and what I have to do to make it work again.
private void addSMS()
{
Uri uri = Uri.parse("content://sms/");
ContentValues cv2 = new ContentValues();
cv2.put("address", "+91956322222");
cv2.put("date", "1309632433677");
cv2.put("read", 1);
cv2.put("type", 2);
cv2.put("body", "Hey");
getContentResolver().insert(uri, cv2);
/** This is very important line to solve the problem */
getContentResolver().delete(Uri.parse("content://sms/conversations/-1"), null, null);
cv2.clear();
}
Starting from Android 4.4 Kitkat, it is not possible to perform any kind of SMS related operations without being the default SMS app. Restore and Backup apps cannot do it either. Most of them have updated their app to support this functionality and now ask the user to select them as the default SMS app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With