目录
@Entity(tableName = "directory")
class Directory(@PrimaryKey(autoGenerate = false) var id: Int? = null,
@ColumnInfo(name = DIR_NAME) var dirName: String? = null,
@Ignore var dirImages: List<Images>? = null
) : Serializable {
companion object {
const val DIR_NAME = "dirName"
const val DIR_IMAGES = "dirImages"
}
}
图像模型
@Entity(foreignKeys = arrayOf(ForeignKey(entity = Directory::class,
parentColumns = arrayOf("id"),
childColumns = arrayOf("id"),
onDelete = ForeignKey.CASCADE)))
data class Images(
@PrimaryKey(autoGenerate = false) val id: Int? = null,
@ColumnInfo(name = "image") val images: String
) {
}
目录道
@Dao
interface DirectoryDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertAll(directory: ArrayList<Directory>?)
}
如何在目录中插入图像列表?我应该为图像创建一个单独的道吗?