[Orm framework for Android]

When developing Android applications, there are several ways to save data,

One is stored locally, one is placed in the background (providing an API interface), and the other is placed on an open cloud service (such as SyncAdapter would be a good choice).

For the first way, a local data store such as embedded SQLite, you can choose to use SQL statements directly, Content Provider or ORM (Object Relational Data Mapping).

For the development of Android applications, the Java language is mainly used, so some ORMs suitable for the Java language can also be transplanted on the Android platform.

 

Here is an overview of the 5 available ORMs:

1. OrmLite

OrmLite is not an ORM framework dedicated to the Android platform, it is a Java ORM. Support JDBC connection, Spring and Android platform. Annotations are used extensively in the grammar.

Official website: http://ormlite.com/sqlite_java_android_orm.shtml

 

2. SugarORM

SugarORM is an Android platform-specific ORM. Provides easy-to-learn APIs. 1-to-1 and 1-to-many relational data can be easily handled, and CRUD basic operations are simplified by three functions save(), delete() and find() (or findById()).

 

 

3. GreenDAO

When performance is important (data access is frequent), GreenDao is a fast solution, it can support CRUD of thousands of records per second, and GreenDAO is almost 4.5 times faster than OrmLite. (Please benchmark yourself for accurate data).

 

greenDAO is an open source Android ORM making development for SQLite databases fun again. It relieves developers from dealing with low-level database requirements while saving development time. SQLite is an awesome embedded relational database. Still, writing SQL and parsing query results are quite tedious and time-consuming tasks. greenDAO frees you from these by mapping Java objects to database tables (called ORM, “object/relational mapping”). This way you can store, update, delete, and query for Java objects using a simple object oriented API.

 

greenDAO’s Features at a glance

  • Maximum performance (probably the fastest ORM for Android); our benchmarks are open sourced too
  • Easy to use powerful APIs covering relations and joins
  • Minimal memory consumption
  • Small library size (<100KB) to keep your build times low and to avoid the 65k method limit
  • Database encryption: greenDAO supports SQLCipher to keep your user’s data safe
  • Strong community: More than 5.000 GitHub stars show there is a strong and active community

 

 

4. Active Android

Active Record (Active Directory) is a typical naming method for ORM implementations in frameworks such as Yii and Rails. Active Android helps you manipulate SQLite in an object-oriented way.

To include Active Android in your project, you need to add a jar file code in the project's /libs directory and edit it using Maven.

 

 

 

5. Realm

Realm is a ready-to-use Android ORM, written in C++, that runs directly on your device hardware (no need to be interpreted), so it runs fast. It is also open source and cross-platform, the code for iOS can be found on GitHub, and you can also find examples of using Realm in Objective-C and Swift.

Official website: http://realm.io/

 

There are mainly several implementation methods used by the ORM framework:

1. Annotation (annotation at runtime, annotation at compile time)

2. Reflection

3. Generate code directly

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326200150&siteId=291194637