我想在我的应用程序中缓存一个歌曲列表,歌曲列表结构如下所示:
@Entity
public class Songlist {
String _id;
String desc;
List songWithComment;
.....
public static class SongDesc {
String comment;
Song song;
}
}
@Entity
pulbic class Song {
String name;
String type;
......
}
运行sqlite3的lib是android.arch.persistence.room,但是它不允许在表中引用对象.是否有任何方法可以通过在Android中使用Room来缓存歌曲列表?
解决方法:
另外,如果您要存储一些自定义对象,则可以使用@Embedded注释,例如在bellow示例中:
class Address {
public String street;
public String state;
public String city;
@ColumnInfo(name = "post_code")
public int postCode;
}
@Entity
class User {
@PrimaryKey
public int id;
public String firstName;
@Embedded
public Address address;
}
标签:android-room,arrays,android
来源: https://codeday.me/bug/20191110/2014290.html