插入新数据后,房间数据库仍然为空。
道
@Insert(onConflict = REPLACE)
fun insert(note: Note): Long
每次插入时都会返回ID,并且ID会递增,但是用SQL查看器查看时我看不到任何表或记录
数据库
db = Room.databaseBuilder(
context.applicationContext,
LocalDb::class.java, "LocalDb"
)
.build()
注意
@Entity(indices = [Index(value = ["text"], unique = true)])
class Note(
var modifiedTime: Long = System.currentTimeMillis(),
var text: String = "",
var isLocked: Boolean = false,
@Ignore
var reminder: Reminder = Reminder(),
var saved: Boolean = false,
@Ignore
@get:Exclude var drawing: MutableSet<Media> = mutableSetOf(),
@Ignore
@get:Exclude var media: MutableSet<Media> = mutableSetOf(),
@PrimaryKey(autoGenerate = true)
var rowid: Int = 0
) : ItemBase(NOTE)