简体   繁体   中英

Entity Framework and Linq equivalent in Android

I am new to Android. I literally just learn Android few days ago. I am just wondering, is there Entity Framework and LINQ equivalent for Android?

Also, I need to store/cache record to a local database. What the best database to use? I am thinking of using SQLite. Is it appropriate for Android?

Thanks!

You need an ORM(Object-Relational Mapper), there is a good cross platform ORM called Realm , Realm gives you a much more programmatic way of accessing and storing data in Objects just like LinQ or EntityFramework and executes queries pragmatically in an object oriented manner.

Sample Realm Code

RealmResults<User> result = realm.where(User.class)
                                 .greaterThan("age", 10)  // implicit AND
                                 .beginGroup()
                                      .equalTo("name", "Peter")
                                      .or()
                                      .contains("name", "Jo")
                                 .endGroup()
                                 .findAll();

Documentation

SqLite is appropriate to store local Data for example: if you are retrieving JSON, u can us an sqlite database to store some data for the offline mode, and of course u can use the cache as well, but i recommend u SQLite.

Hope i helped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM