Realm-Android 灰太狼 2022-07-15 08:47 160阅读 0赞 ![SouthEast][] Realm Java 让你能够高效地编写 app 的模型层代码,保证你的数据被安全、快速地存储。参考下列示例来开始你的 Realm 之旅: // Define you model class by extending RealmObject public class Dog extends RealmObject { private String name; private int age; // ... Generated getters and setters ... } public class Person extends RealmObject { @PrimaryKey private long id; private String name; private RealmList<Dog> dogs; // Declare one-to-many relationships public Person(long id, String name) { this.id = id; this.name = name; } // ... Generated getters and setters ... } // Use them like regular java objects Dog dog = new Dog(); dog.setName("Rex"); dog.setAge(1); // Init [SouthEast]: /images/20220715/252147313b634b27b868ecac495937fc.png
还没有评论,来说两句吧...