Created NoteTypeConverter

This commit is contained in:
merkost 2023-07-10 11:20:10 +10:00
parent e8b8d2be1d
commit 0112f39ff0
2 changed files with 16 additions and 0 deletions

View File

@ -17,6 +17,7 @@ import java.io.File
*/
@Serializable
@Entity(tableName = "notes", indices = [(Index(value = ["id"], unique = true))])
@TypeConverters(NoteTypeConverter::class)
data class Note(
@PrimaryKey(autoGenerate = true) var id: Long?,
@ColumnInfo(name = "title") var title: String,

View File

@ -0,0 +1,15 @@
package com.simplemobiletools.notes.pro.models
import androidx.room.TypeConverter
class NoteTypeConverter {
@TypeConverter
fun fromNoteType(noteType: NoteType): Int {
return noteType.value
}
@TypeConverter
fun toNoteType(value: Int): NoteType {
return NoteType.fromValue(value)
}
}