{"id":21858105,"url":"https://github.com/cesarferreira/rxpaper","last_synced_at":"2025-07-27T15:42:45.333Z","repository":{"id":57718191,"uuid":"46756855","full_name":"cesarferreira/RxPaper","owner":"cesarferreira","description":"Reactive extension for NoSQL data storage on Android","archived":false,"fork":false,"pushed_at":"2017-02-20T12:33:25.000Z","size":134,"stargazers_count":176,"open_issues_count":0,"forks_count":20,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-28T07:21:52.818Z","etag":null,"topics":["android","kryo","no-sql","storage"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cesarferreira.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-24T00:32:47.000Z","updated_at":"2023-02-02T10:44:13.000Z","dependencies_parsed_at":"2022-09-14T22:41:39.422Z","dependency_job_id":null,"html_url":"https://github.com/cesarferreira/RxPaper","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesarferreira%2FRxPaper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesarferreira%2FRxPaper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesarferreira%2FRxPaper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesarferreira%2FRxPaper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cesarferreira","download_url":"https://codeload.github.com/cesarferreira/RxPaper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248942221,"owners_count":21186938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","kryo","no-sql","storage"],"created_at":"2024-11-28T02:42:23.987Z","updated_at":"2025-04-14T18:53:44.881Z","avatar_url":"https://github.com/cesarferreira.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RxPaper\n\u003ca href=\"http://www.methodscount.com/?lib=com.cesarferreira.rxpaper%3Arxpaper%3A0.4.1\"\u003e\u003cimg src=\"https://img.shields.io/badge/Size-11 KB-e91e63.svg\"/\u003e\u003c/a\u003e [![Build Status](https://travis-ci.org/cesarferreira/RxPaper.svg?branch=master)](https://travis-ci.org/cesarferreira/RxPaper)\n\n\nRxPaper is a [RxJava](https://github.com/ReactiveX/RxJava) wrapper for the cool [paper](https://github.com/pilgr/Paper) library, a [fast](#benchmark-results) NoSQL data storage for Android that lets you **save/restore** Java objects by using efficient [Kryo](https://github.com/EsotericSoftware/kryo) serialization and handling data structure changes automatically.\n\nFor the RxJava 2 version please go to [RxPaper2](https://github.com/pakoito/RxPaper2) made by [Pakoito](https://github.com/pakoito).\n\n\n![Paper icon](https://raw.githubusercontent.com/pilgr/Paper/master/paper_icon.png)\n\n\n### What's new for the new `PaperDB 2.0` (starting on `0.5.0`+ version)\n* Update internal Kryo serializer to 4.0. The data format is changed, but Paper supports backward data compatibility automatically;\n* Now 58% less methods count : [4037](http://www.methodscount.com/?lib=io.paperdb%3Apaperdb%3A2.0);\n* Depends on data structure you may experience faster reading but slower writing.\n\n#### Add dependency\n```groovy\nrepositories {\n    jcenter()\n    maven { url \"https://jitpack.io\" }\n }\ndependencies {\n    compile 'com.cesarferreira.rxpaper:rxpaper:0.5.0'\n}\n```\n\n#### Install\n\nInit the library in your Application class\n\n```java\npublic class SampleApplication extends Application {\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n\n        RxPaper.init(this);\n    }\n}\n\n```\n\n\n#### Save\nSave data object. **Your custom classes must have no-arg constructor.**\nPaper creates separate data file for each key.\n\n```java\nRxPaper.book()\n        .write(key, value)\n        .subscribe(success -\u003e /* all good */ );\n\n```\nI'm serious: **Your custom classes must have no-arg constructor.**\n\n#### Read\nRead data objects. Paper instantiates exactly the classes which has been used in saved data. The limited backward and forward compatibility is supported. See [Handle data class changes](#handle-data-structure-changes).\n\nUse default values if object doesn't exist in the storage.\n\n```java\n\nRxPaper.book()\n        .read(key, defaultPersonValue)\n        .subscribe(person -\u003e /* all good */ );\n\n```\n\n\n#### Delete\nDelete data for one key.\n\n```java\nRxPaper.book()\n       .delete(key)\n       .subscribe();\n```\n\nCompletely destroys Paper storage.\n\n```java\nRxPaper.book()\n       .destroy()\n       .subscribe();\n```\n\n#### Exists\nCheck if a key is persisted\n\n```java\nRxPaper.book()\n       .exists(key)\n       .subscribe(success -\u003e /* all good */);\n```\n\n#### Get all keys\n\nReturns all keys for objects in the book.\n\n```java\nRxPaper.book()\n       .getAllKeys()\n       .subscribe(allKeys -\u003e /* all good */);\n```\n\n#### Use custom book\nYou can create custom Book book separate storage using\n\n```java\nRxPaper.book(\"custom-book\")...;\n```\n\nAny changes in one book doesn't affect to others books.\n\n\n## Important information\n\nDon't forget to specify which threads you want to use before subscribing to any data manipulation, or else it'll run on the UI thread.\n\n```java\n...\n.subscribeOn(Schedulers.io())\n.observeOn(AndroidSchedulers.mainThread())\n.subscribe(...\n ```\n\n\n#### Handle data structure changes\nClass 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:\n\n```java\nclass Person {\n    public String firstName; // Cesar\n    public String middleName; // Costa\n}\n```\n\nAnd then you realized you need to change the class like:\n\n```java\nclass Person {\n    public String firstName; // Cesar\n    // public String middleName; removed field, who cares about middle names\n    public String lastName; // New field\n}\n```\n\nThen on restore the _middleName_ field will be ignored and new _lastName_ field will have its default value _null_.\n\n#### Exclude fields\nUse _transient_ keyword for fields which you want to exclude from saving process.\n\n```java\npublic transient String tempId = \"default\"; // Won't be saved\n```\n#### Proguard config\n* Keep data classes:\n\n```\n-keep class my.package.data.model.** { *; }\n```\n\nalternatively you can implement _Serializable_ in all your data classes and keep all of them using:\n\n```\n-keep class * implements java.io.Serializable { *; }\n```\n\n* Keep library classes and its dependencies\n\n```\n-keep class io.paperdb.** { *; }\n-keep class com.esotericsoftware.** { *; }\n-dontwarn com.esotericsoftware.**\n-keep class de.javakaffee.kryoserializers.** { *; }\n-dontwarn de.javakaffee.kryoserializers.**\n```\n\n#### How it works\nPaper is based on the following assumptions:\n- Saved data on mobile are relatively small;\n- Random file access on flash storage is very fast.\n\nSo each data object is saved in separate file and write/read operations write/read whole file.\n\nThe [Kryo](https://github.com/EsotericSoftware/kryo) is used for object graph serialization and to provide data compatibility support.\n\n#### Benchmark results\nRunning [Benchmark](https://github.com/pilgr/Paper/blob/master/paperdb/src/androidTest/java/io/paperdb/benchmark/Benchmark.java) on Nexus 4, in ms:\n\n| Benchmark                 | Paper    | [Hawk](https://github.com/orhanobut/hawk)\n|---------------------------|----------|----------\n| Read/write 500 contacts   | 187      | 447                |\n| Write 500 contacts        | 108      | 221               |\n| Read 500 contacts         | 79       | 155                |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesarferreira%2Frxpaper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcesarferreira%2Frxpaper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesarferreira%2Frxpaper/lists"}