Code is the best teacher

1. An overview of the

  1. SQLite is a lightweight relational database on the Android platform.
  2. High efficiency and low resource consumption
  3. The native operation of SQLite requires the help of the SQLiteOpenHelper class, and the actual development generally uses the database framework
  4. Mature frameworks for commercial use include GreendAO3 +, Litepal, DBFlow, and the alternative Realm

2.greendao

GreenDao uses the full solution

Greendao has the following advantages and is the first choice when building the project framework:

  1. Fast access speed
  2. Support encryption
  3. Lightweight, minimal API
  4. Support the cache
  5. The intermediate code is automatically generated, and the code writing is small
  6. Open source up to now, through tempered, stable and reliable

Making direct GreenDao

3.LitePal

LitePal uses the full solution

LitePal is an open source database framework.

LitePal has the same advantages as Greendao.

The performance and resource usage vary with the amount of data and operation. But in the 2020s, these nuances are almost invisible.

In specific commercial use, greendao will be more chosen in pursuit of stability. The reason is not that LitePal is weak, but that Greendao has a large use base, so that it tends to be perfect. LitePal up-and-coming, and version iteration, using cardinality, open source test is less.

Making direct LitePal

4.Realm

GitHub directly to Android Realm

Realm is an ios/ Android framework designed specifically for mobile

It has the advantages of simple use, excellent performance and cross-platform, among which cross-platform is its biggest advantage compared with other databases.

But,

  1. Realm does not support federated primary keys;
  2. A realm instance cannot be used across threads;
  3. Access can only be on an object basis
  4. Self-growing primary keys are not supported
  5. Changes to the query results are synchronized directly to the database

Therefore, the project architecture phase needs to weigh the data usage and consider using Realm cross-platform databases

5.DBFlow

Making direct DBFlow

DBFlow uses the full solution

DBFlow is an ORM framework for AnnotationProcessing:

  1. The same coding mindset as Springboot allows development to focus on logic rather than rigid DB code
  2. Supports synchronous/asynchronous/transactional operations
  3. Supports custom database storage paths
  4. Flexible, concise and readable
  5. Compile-time code generation is zero cost to performance at run time, comparable to other database frameworks
  6. Support lazy loading
  7. You can directly annotate the Content Provider dependent Schematic library