Visit GitHub RepoNoSQL

Join the chat at Android Arsenal Codacy Badge


Fast and easy to use NoSQL data storage with RxJava and Kotlin support

Android sdk version 8 support

Add dependency

Add apt plugin in your top level gradle build file

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

Apply apt plugin in your application gradle build file.

apply plugin: ''

Add dependencies to your application gradle build file

The Core

compile 'io.fabianterhorst:iron:0.8.0'

The Extensions

compile 'io.fabianterhorst:iron-retrofit:0.8.0'
compile 'io.fabianterhorst:iron-encryption:0.8.0'
//is only required for using the compiler
compile 'io.fabianterhorst:iron-annotations:0.8.0'
apt 'io.fabianterhorst:iron-compiler:0.8.0'

Initiate Iron instance with application context

public class MyApplication extends Application {
    public void onCreate() {
        Iron.setCache(Cache.MEMORY);//default is NONE
        //Optional if iron-retrofit is included
        Iron.setLoader(new IronRetrofit());
        //Optional if iron-encryption is included
        Iron.setEncryption(new IronEncryption());

Use the @Store annotation on any plain old Java object.

public class Main {
    @Name(value = "contributor_list", transaction = true, listener = true, loader = true, async = true)
    ArrayList<Contributor> contributors;

    String userName;

    Long myLong;

Now you can access the generated Methods from your Main + "Store" file.


Get value synced


Get value asynced

MainStore.getContributors(new Chest.ReadCallback<ArrayList<Contributor>>() {
    public void onResult(ArrayList<Contributor> contributors) {

Remove value

 Iron.chest().addOnDataChangeListener(new DataChangeCallback(this) {
    public void onDataChange(String key, Object value) {
            Log.d(TAG, ((ArrayList<Contributor>)value).toString());

transactions (changes will be saved)

 MainStore.executeContributorsTransaction(new Chest.Transaction<ArrayList<Contributor>>() {
    public void execute(ArrayList<Contributor> contributors) {
    	Contributor contributor = new Contributor();

Use a internal transaction to add a object to the list and save it automatically

Contributor contributor = new Contributor();

Use a internal transaction to add objects to the list and save it automatically

ArrayList<Contributor> contributors = new ArrayList<>();
for(int i = 0;i < 10;i++){
    Contributor contributor = new Contributor();
    contributor.setName("name" + i);

Data change listener

MainStore.addOnContributorsDataChangeListener(new DataChangeCallback<ArrayList<Contributor>>(this) {
    public void onDataChange(ArrayList<Contributor> value) {

Generic data change listener

MainStore.addOnDataChangeListener(new DataChangeCallback(this) {
    public void onDataChange(String key, Object value) {
            //contributors changed

Search for object with field and value

MainStore.getContributorsForField("login", "fabianterhorst", new Chest.ReadCallback<Contributor>() {
    public void onResult(Contributor contributor) {
        if(contributor != null)
            Log.d(TAG, contributor.toString());

RxJava support

Set a value asynchron with RxJava

Iron.chest().set("name", "Fabian");

Get a value asynchron with RxJava

Iron.chest().<String>get("name").compose(this.<String>bindToLifecycle()).subscribe(new Subscriber<String>() {

            public void onError(Throwable e) {

            public void onNext(String s) {
                //called when name changed and when name was loaded asynchron
                Log.d("name", s);

            public void onCompleted() {


With RxJava the Retrofit extension isn´t needed anymore.

Observable<List<Repo>> reposCallObservable = service.listReposRxJava("fabianterhorst");
Iron.chest().load(reposCallObservable, Repo.class);

You can also use Iron.chest()´s methods.

Iron.chest().write("username", "fabian");

Read data objects. Iron instantiates exactly the classes which has been used in saved data. The limited backward and forward compatibility is supported.

String username = Iron.chest().read("username");

Laod and save data with retrofit. Need loader extension to be added in application.

Call<List<Repo>> reposCall = service.listRepos("fabianterhorst");
Iron.chest().load(reposCall, Repo.class);

Get value asynced with default value

Iron.chest().get("contributors", new Chest.ReadCallback<ArrayList<Contributor>>() {
    public void onResult(ArrayList<Contributor> contributors) {      
}, new ArrayList<Contributor>());

Remove listener to prevent memory leaks

protected void onDestroy() {

Handle data structure changes

Class fields which has been removed will be ignored on restore and new fields will have their default values. For example, if you have following data class saved in Paper storage:

class User {
    public String name; //Fabian
    public boolean isActive;

And then you realized you need to change the class like:

class User {
    public String name; //Fabian
    // public boolean isActive; removed field
    public Location location; // New field

Then on restore the isActive field will be ignored and new location field will have its default value null.

Retrofit support

Call<List<Contributor>> userCall = service.contributors("fabianterhorst", "iron");

with Cache:

Running Benchmark on Nexus 6p, in ms:

Benchmark Iron Hawk sqlite
Read/write 500 contacts 29 142
Write 500 contacts 27 60
Read 500 contacts 0 63

Running Benchmark on Emulator, in ms:

Benchmark Iron Hawk sqlite
Read/write 500 contacts 12 54
Write 500 contacts 11 25
Read 500 contacts 0 24

with Encryption (only in Iron):

Running Benchmark on Nexus 6p, in ms:

Benchmark Iron Hawk sqlite
Read/write 500 contacts 53 142
Write 500 contacts 28 61
Read 500 contacts 23 63

Snapshot Builds

Add the jitpack repository in your root build.gradle at the end of repositories

allprojects {
    repositories {
        maven { url "" }
//Latest commit
compile 'com.github.FabianTerhorst:Iron:-SNAPSHOT'


Copyright 2016 Fabian Terhorst

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
Become a better Android Developer
Millions of developers are learning at MindOrks

Online Training Program

Featured Blogs

Our Team

MindOrks is Certainly one of the best online blog to stay on top of all the Android development news, coding and design patterns. Finally a blog I can count on to keep myself updated with latest and greatest things happening in Android world.

Vipul Shah
Android Developer

Become Pro in Android by watching videos