{"id":13989290,"url":"https://github.com/rehacktive/waspdb","last_synced_at":"2025-07-27T06:35:39.500Z","repository":{"id":149775094,"uuid":"56782018","full_name":"rehacktive/waspdb","owner":"rehacktive","description":"key/value data storage library for Android, pure java and encrypted","archived":false,"fork":false,"pushed_at":"2019-03-11T10:35:21.000Z","size":373,"stargazers_count":226,"open_issues_count":2,"forks_count":22,"subscribers_count":13,"default_branch":"dev","last_synced_at":"2025-05-08T00:29:05.462Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rehacktive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-04-21T14:48:43.000Z","updated_at":"2024-08-03T09:41:49.000Z","dependencies_parsed_at":"2023-05-09T13:31:43.766Z","dependency_job_id":null,"html_url":"https://github.com/rehacktive/waspdb","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/rehacktive/waspdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehacktive%2Fwaspdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehacktive%2Fwaspdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehacktive%2Fwaspdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehacktive%2Fwaspdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rehacktive","download_url":"https://codeload.github.com/rehacktive/waspdb/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehacktive%2Fwaspdb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267317701,"owners_count":24068481,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-08-09T13:01:35.624Z","updated_at":"2025-07-27T06:35:39.482Z","avatar_url":"https://github.com/rehacktive.png","language":"Java","funding_links":[],"categories":["Java","数据库"],"sub_categories":[],"readme":"[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-WaspDb-green.svg?style=true)](https://android-arsenal.com/details/1/3482)\n\nlast release: 1.1.1\n\n(note: this version is NOT compatible with 1.0, read the release message)\n\n\n# WaspDb \nWaspDB is a pure Java key/value (NoSQL) database library for Android. It supports AES256 encryption for all the disk storage. It's very small (the aar file is ~189 KB).\n\nKeys and Values are simple Java Objects. Everything is automatically serialized using the [Kryo](https://github.com/EsotericSoftware/kryo/) serialization library.\n\nData is stored by an implementation of hashmaps on disk.\n\n\n### QuickStart\n\nTo use it with gradle (using jitpack.io):\n\nAdd it in your root build.gradle at the end of repositories:\n\n```groovy\nallprojects {\n\trepositories {\n\t\t...\n\t\tmaven { url \"https://jitpack.io\" }\n\t}\n}\n```\nAdd the dependency\n\n```groovy\ndependencies {\n\t...\n\tcompile 'com.github.rehacktive:waspdb:1.1.1'\n}\n```\n\nOk, let's start.\n\t\nLet's assume a POJO (even with nested object, like Address):\n```java\nclass User {\n\tprivate String username;\n\tprivate String email;\n\tprivate String telephone;\n\tprivate Address address;\n\t\n\tpublic User() {\n\t}\n\t\n\t// getters and setters...\n}\n```\n\nNo need to be Serializable or Parcelable or annotations or extending/implementing from other classes/interfaces, the only important thing is to have an **empty constructor**.\n\t\n**Create a database, a WaspHash and store a POJO**\n```java\n// create a database, using the default files dir as path, database name and a password\nString path = getFilesDir().getPath();\nString databaseName = \"myDb\";\nString password = \"passw0rd\";\n    \nWaspDb db = WaspFactory.openOrCreateDatabase(path,databaseName,password);\n\t\n// now create an WaspHash, it's like a sql table\nWaspHash users = db.openOrCreateHash(\"users\");\n\n// now let's have a POJO\nUser p = new User();\n... // do your stuff with your POJO!\n\n// and simply store it!\nusers.put(p.getUsername(), p);\n```\n\n**To retrieve it**, it's just\n```java\nUser p = users.get(\"username1\");\n```\n\n**Need all your objects?**\n```java\nList\u003cUser\u003e allUsers = users.getAllValues();\n```\n\nIt returns all the users, in a standard java List.\n\nOr you can **get all the keys** used\n```java\nList\u003cString\u003e keys = users.getAllKeys();\n```\nor the actual **key/value map** (it's again a standard java class)\n```java\nHashMap\u003cString, User\u003e usersMap = users.getAllData();\n```\nPlease note that the process of creating an encrypted database is computationally expensive (10000 iterations to create the AES256 key), so also an async method is available:\n```java\t\nWaspFactory.openOrCreateDatabase(path, databaseName, password, new WaspListener\u003cWaspDb\u003e() {\n        @Override\n        public void onDone(WaspDb waspDb) {\n            ....\n        }\n    });\n```\n\t\n### Why WaspDb\nI **hate** to store objects on sqlite! It's a lot of boiler code...for what?\nOkay, let's say in the polite way :)\n\n\tThe object-relational impedance mismatch is a set of conceptual and technical difficulties that are often encountered when a relational database management system (RDBMS) is being used by a program written in an object-oriented programming language or style; particularly when objects or class definitions are mapped in a straightforward way to database tables or relational schema. \n(from wikipedia [https://en.wikipedia.org/wiki/Object-relational_impedance_mismatch](https://en.wikipedia.org/wiki/Object-relational_impedance_mismatch))\n\n### What WaspDb is NOT\nThis is not a SQL database. It does not have a relational data model, it does not support SQL queries, and it provides no support for indexes, nor transactions.\n\n### Features\n- it's pure java, it's standalone, no native stuff, it's not an ORM to SqlLite!\n\n- the database addresses up to 4294967296 keys for WaspHash...enough? :)\n\n### Limitations\n- it's NOT transactional. So if you wanna store 10000, it will make 10000 actual write operations to disk in sequence. That means it will be slower (in this case) compared to transactional databases. (of course, if you store 100 items as a java List - so actually a single object - it will make a single(ish) write operation)\n\n### Proguard \nIf you use Proguard in your project, add this to your proguard rules in order to skip WaspDB/Kryo classes:\n\t\n\t-keep class net.rehacktive.waspdb.** { *; }\n\t-keep class com.esotericsoftware.kryo.** { *; }\n\n### Performances\n\nI've used this project [https://github.com/Raizlabs/AndroidDatabaseLibraryComparison](https://github.com/Raizlabs/AndroidDatabaseLibraryComparison) to make some benchmarking.\n\nThis is the \"simple trial\" (storing 50 objects) on a Nexus 5, using WaspDb's encryption feature:\n\n![image](/images/wasp_comparison.png)\n\nIt's even faster if you don't need encryption.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehacktive%2Fwaspdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frehacktive%2Fwaspdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehacktive%2Fwaspdb/lists"}