creating a database table for MessageAttachments too
This commit is contained in:
parent
0f33d3677b
commit
b955678e90
5 changed files with 50 additions and 2 deletions
|
|
@ -0,0 +1,17 @@
|
|||
package com.simplemobiletools.smsmessenger.helpers
|
||||
|
||||
import androidx.room.TypeConverter
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.simplemobiletools.smsmessenger.models.Attachment
|
||||
|
||||
class Converters {
|
||||
private val gson = Gson()
|
||||
private val attachmentType = object : TypeToken<List<Attachment>>() {}.type
|
||||
|
||||
@TypeConverter
|
||||
fun jsonToAttachmentList(value: String) = gson.fromJson<ArrayList<Attachment>>(value, attachmentType)
|
||||
|
||||
@TypeConverter
|
||||
fun attachmentListToJson(list: ArrayList<Attachment>) = gson.toJson(list)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue