store received SMS in the SMS provider
This commit is contained in:
parent
3eb1127c74
commit
654359eaea
2 changed files with 23 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package com.simplemobiletools.smsmessenger.extensions
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.provider.ContactsContract
|
||||
|
|
@ -158,3 +159,15 @@ fun Context.getNameFromPhoneNumber(number: String): Int? {
|
|||
|
||||
return null
|
||||
}
|
||||
|
||||
fun Context.insertNewSMS(address: String, subject: String, body: String, date: Long) {
|
||||
val uri = Telephony.Sms.CONTENT_URI
|
||||
val contentValues = ContentValues().apply {
|
||||
put(Telephony.Sms.ADDRESS, address)
|
||||
put(Telephony.Sms.SUBJECT, subject)
|
||||
put(Telephony.Sms.BODY, body)
|
||||
put(Telephony.Sms.DATE, date)
|
||||
}
|
||||
|
||||
contentResolver.insert(uri, contentValues)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue