Recommended Android ORM Framework

Source: Internet
Author: User

1. Ormlite

Ormlite is not a dedicated ORM framework for the Android platform, it is a Java ORM. Supports JDBC connection, spring and Android platform. Annotations (Annotation) are widely used in the syntax.

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

2. Sugarorm

Sugarorm is a dedicated ORM for the Android platform. Provide easy-to-learn APIs. It is easy to process 1 pairs of 1 and 1-to-many relational data and simplify CRUD basic operations with 3 functions, save (), delete (), and find () (or FindByID ()).

To enable Sugarorm, you need to add the following meta-data tags in your application's androidmanifest.xml configuration:

<meta-data android:name= "DATABASE" android:value= "my_database.db"/><meta-data android:name= "VERSION" Android:value= "1"/><meta-data android:name= "Query_log" android:value= "true"/><meta-data android:name= "Domain_package_name" android:value= "Com.my-domain"/>

You can then extend the data classes you need to save from Sugarorm:

public class User extends sugarrecord<user> {String username; String password;int age; @IgnoreString bio; This would be ignored by Sugarormpublic user () {}public User (string username, string Password,int age) {this.username = u Sername;this.password = Password;this.age = Age;}}

To add a user, the code is as follows:

User JohnDoe = New User (GetContext (), "John.doe", "secret", +); Johndoe.save (); Stores the new user into the database

Official website: http://satyan.github.io/sugar/getting-started.html

3. Greendao

When performance is important (data access is frequent), Greendao is a quick solution that can support thousands of records of crud per second, and Ormlite is almost 4.5 times times faster than Greendao. (Please benchmark the exact data).

Greendao is less than 100KB, so it has little effect on the size of the app apk.

Here's a tutorial that shows how to use Android Studio to use the Greendao framework in Android apps.

Official website: http://greendao-orm.com/

4. Active Android

Active Record (Active Directory) is a typical way of naming ORM implementations in frameworks such as Yii, rails, and so on. 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 under the project's/libs directory. You can get the source code from GitHub and edit it using Maven. Then you should add these meta-data to your application's Androidmanifest.xml configuration:

<meta-data android:name= "Aa_db_name" android:value= "my_database.db"/><meta-data android:name= "AA_DB_ VERSION "android:value=" 1 "/>

Then call the Activeandroid.initialize () method in your activity:

public class MyActivity extends Activity {@Overridepublic void onCreate (Bundle savedinstancestate) {super.oncreate ( Savedinstancestate); Activeandroid.initialize (this);//rest of the App}}

Now you can use Java annotations to create a model class:

@Table (name = "User") public class User extends Model {@Column (name = "username") public String username; @Column (name = "Pas Sword ") Public String password;public User () {super ();} Public User (String username,string password) {super (); this.username = Username;this.password = password;}}

Official website: http://www.activeandroid.com/

5. Realm

Realm is a ready-to-use Android ORM that is written in C + + and runs directly on your device hardware (no need to be interpreted), so it runs quickly. It is also open source cross-platform, iOS code can be found on GitHub, you can also find objective-c and swift written realm usages.

Official website: http://realm.io/

Recommended Android ORM Framework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.