代替SQLite的手机数据库:Realm
jopen
10年前
Realm是一个能够代替SQLite和Core Data的手机数据库。使用 C++ 内核,所以效率非常的高,是 sqlite 的近几倍。
特性:
- Mobile-first: Realm is the first database built from the ground up to run directly inside phones, tablets and wearables.
- Simple: Data is directly exposed as objects and queryable by code, removing the need for ORM's riddled with performance & maintenance issues. Plus, we've worked hard to keep our API down to very few classes: most of our users pick it up intuitively, getting simple apps up & running in minutes.
- Modern: Realm supports easy thread-safety, relationships & encryption.
- Fast: Realm is faster than even raw SQLite on common operations, while maintaining an extremely rich feature set.
Realm 中文文档:http://djyde.github.io/2014/10/17/realm-doc-in-chinese.html
Realm realm = Realm.getInstance(this); // All writes are wrapped in a transaction // to facilitate safe multi threading realm.beginTransaction(); // Add a person Person person = realm.createObject(Person.class); person.setName("Young Person"); person.setAge(14); realm.commitTransaction(); RealmResults<User> result = realm.where(User.class) .greaterThan("age", 10) // implicit AND .beginGroup() .equalTo("name", "Peter") .or() .contains("name", "Jo") .endGroup() .findAll();