百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

ReActiveAndroid

> 数据库
开源

适用于 Android 的简单而强大的 ORM

99 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

适用于 Android 的简单而强大的 ORM

logo

Full Documentation: ReActiveAndroid

ReActiveAndroid is Android ORM based on popular library ActiveAndroid. Unfortunately, the author of the library stopped maintaining it, so I decided to continue maintain the library instead of him.

New features in ReActiveAndroid in comparison with ActiveAndroid:

  • multiple databases support
  • more convenient migration mechanism
  • a new and improved syntax for creating SQL queries
  • One-to-Many relation
  • inherited models
  • table/model change notifications
  • RxJava 2 support
  • fixed bugs and more

In the plans:

  • Annotation Processing instead of Java Reflection
  • improved compatibility with Kotlin
  • composite primary key support
  • SQL Cipher support
  • AutoValue support

Installation

Add this to your app build.gradle:

gradle
implementation 'com.reactiveandroid:reactiveandroid:1.4.3'

Initial setup

First, we need to create a database class:

java
@Database(name = "MyDatabase", version = 1)
public class AppDatabase {

}

In the @Database annotation we specified the name of the database without an extension and the version of the schema.

Next, we need to initialize the library in the onCreate method of the Application class:

java
DatabaseConfig appDatabase = new DatabaseConfig.Builder(AppDatabase.class)
        .build();

ReActiveAndroid.init(new ReActiveConfig.Builder(this)
        .addDatabaseConfigs(appDatabase)
        .build());

Creating tables

To create a table, we need to create a model class that inherits from the Model class and annotate it with @Table:

…

In the @Table annotation we specify table name and the database class in which the table belongs. Also you can create a model class without inheritance from the Model, but then you will not have access to save() and delete() methods.

Now we can save, update and delete records:

java
Note note = new Note("Title", "Text");
note.save();

note.setText("New text");
note.save();

note.delete();

Query building

Building a query in ReActiveAndroid is like building a normal SQL statement:

java
//inserting record
Insert.into(Note.class).columns("title", "text").values("Title", "Text").execute();

//getting all table records
List notes = Select.from(Note.class).fetch();

//getting a specific record
Note note = Select.from(Note.class).where("id = ?", 1).fetchSingle();

//getting a selection of records
List notes = Select.from(Note.class).where("title = ?", "title").fetch();

//updating record
Update.table(Note.class).set("title = ?", "New title").where("id = ?", 1).execute();

//deleting record
Delete.from(Note.class).where("id = ?", 1).execute();

License

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javaactiveandroidandroiddatabaseorm

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库