{"id":18892394,"url":"https://github.com/hf/leveldb-android","last_synced_at":"2025-10-06T02:44:22.066Z","repository":{"id":17250298,"uuid":"20019638","full_name":"hf/leveldb-android","owner":"hf","description":"LevelDB bindings for Android.","archived":false,"fork":false,"pushed_at":"2020-01-30T16:15:28.000Z","size":267,"stargazers_count":56,"open_issues_count":3,"forks_count":18,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-27T11:37:17.380Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hf.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}},"created_at":"2014-05-21T12:01:04.000Z","updated_at":"2025-09-23T15:25:36.000Z","dependencies_parsed_at":"2022-08-26T23:21:18.575Z","dependency_job_id":null,"html_url":"https://github.com/hf/leveldb-android","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/hf/leveldb-android","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fleveldb-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fleveldb-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fleveldb-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fleveldb-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hf","download_url":"https://codeload.github.com/hf/leveldb-android/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fleveldb-android/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277371827,"owners_count":25806945,"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-09-28T02:00:08.834Z","response_time":79,"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-11-08T08:01:54.275Z","updated_at":"2025-10-06T02:44:22.041Z","avatar_url":"https://github.com/hf.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/proxain/leveldb-android.svg?branch=master)](https://travis-ci.org/proxain/leveldb-android) [![codecov](https://codecov.io/gh/proxain/leveldb-android/branch/master/graph/badge.svg)](https://codecov.io/gh/proxain/leveldb-android) [![Download](https://api.bintray.com/packages/stojan/android/leveldb-android/images/download.svg)](https://bintray.com/stojan/android/leveldb-android/_latestVersion)\n# LevelDB for Android\n\n**LOOKING FOR A MAINTAINER. PLEASE WRITE [HERE](https://github.com/hf/leveldb-android/issues/12) IF INTERESTED.**\n\nThis is a Java wrapper for the amazing\n[LevelDB](https://github.com/google/leveldb) by Google.\n\nCurrently it does not use [Snappy](http://google.github.io/snappy/) for data\ncompression. (There is really no need for this in Android, i.e. it's unnecessary\noverhead.)\n\nLevelDB's native log output is tagged: `com.github.hf.leveldb:N`\n\n## Usage\n\nAdd this to your build.gradle:\n\n```groovy\nrepositories {\n  maven {\n    url \"https://dl.bintray.com/stojan/android\"\n  }\n}\n```\n\nAnd then this as a dependency:\n\n```groovy\ndependencies {\n  compile 'com.github.hf:leveldb:1.19.0@aar'\n}\n```\n\nProGuard rules:\n\n```\n-keep class com.github.hf.leveldb.** { *; }\n```\n\nIf you really want to obfuscate LevelDB, then make sure that the exceptions are not obfuscated since those are used within JNI code and will not be resolved properly at runtime.\n\n## Example\n\n### Opening, Closing, Putting, Deleting\n\n```java\nLevelDB levelDB = LevelDB.open(\"path/to/leveldb\", LevelDB.configure().createIfMissing(true));\n\nlevelDB.put(\"leveldb\".getBytes(), \"Is awesome!\".getBytes());\nString value = levelDB.get(\"leveldb\".getBytes());\n\nleveldb.put(\"magic\".getBytes(), new byte[] { 0, 1, 2, 3, 4 });\nbyte[] magic = levelDB.getBytes(\"magic\".getBytes());\n\nlevelDB.close(); // closing is a must!\n```\n\n### WriteBatch (a.k.a. Transactions)\n\n```java\nLevelDB levelDB = LevelDB.open(\"path/to/leveldb\"); // createIfMissing == true\n\nlevelDB.put(\"sql\".getBytes(), \"is lovely!\".getBytes());\n\nlevelDB.writeBatch()\n  .put(\"leveldb\".getBytes(), \"Is awesome!\".getBytes())\n  .put(\"magic\".getBytes(), new byte[] { 0, 1, 2, 3, 4 })\n  .del(\"sql\".getBytes())\n  .write(); // commit transaction\n\nlevelDB.close(); // closing is a must!\n\n```\n\n### Iteration Over Key-Value Pairs\n\nLevelDB is a key-value store, but it has some nice iteration features.\n\nEvery key-value pair inside LevelDB is ordered. Until the comparator wrapper API\nis finished you can iterate over your LevelDB in the key's lexicographical order.\n\n```java\nLevelDB levelDB = LevelDB.open(\"path/to/leveldb\");\n\nIterator iterator = levelDB.iterator();\n\nfor (iterator.seekToFirst(); iterator.isValid(); iterator.next()) {\n  byte[] key   = iterator.key();\n  byte[] value = iterator.value();\n}\n\niterator.close(); // closing is a must!\n```\n\n#### Reverse Iteration\n\n*It is somewhat slower than forward iteration.*\n\n```java\nLevelDB levelDB = LevelDB.open(\"path/to/leveldb\");\n\nIterator iterator = levelDB.iterator();\n\nfor (iterator.seekToLast(); iterator.isValid(); iterator.previous()) {\n  String key   = iterator.key();\n  String value = iterator.value();\n}\n\niterator.close(); // closing is a must!\n```\n\n#### Iterate from a Starting Position\n\n```java\nLevelDB levelDB = LevelDB.open(\"path/to/leveldb\");\n\nIterator iterator = levelDB.iterator();\n\nfor (iterator.seek(\"leveldb\".getBytes()); iterator.isValid(); iterator.next()) {\n  String key   = iterator.key();\n  String value = iterator.value();\n}\n\niterator.close(); // closing is a must!\n```\n\nThis will start from the key `leveldb` if it exists, or from the one that\nfollows (eg. `sql`, i.e. `l` \u003c `s`).\n\n#### Snapshots\n\nSnapshots give you a consistent view of the data in the database at a given time.\n\nHere's a simple example demonstrating their use:\n\n```java\nLevelDB levelDB = LevelDB.open(\"path/to/leveldb\");\n\nlevelDB.put(\"hello\".getBytes(), \"world\".getBytes());\n\nSnapshot helloWorld = levelDB.obtainSnapshot();\n\nlevelDB.put(\"hello\".getBytes(), \"brave-new-world\".getBytes());\n\nlevelDB.get(\"hello\".getBytes(), helloWorld); // == \"world\"\n\nlevelDB.get(\"hello\".getBytes()); // == \"brave-new-world\"\n\nlevelDB.releaseSnapshot(helloWorld); // release the snapshot\n\nlevelDB.close(); // snapshots will automatically be released after this\n```\n\n### Mock LevelDB\n\nThe implementation also supplies a mock LevelDB implementation that is an in-memory \nequivalent of the native LevelDB. It is meant to be used in testing environments,\nespecially non-Android ones like Robolectric.\n\nThere are a few of differences from the native implementation:\n\n+ it is not configurable\n+ it does not support properties (as in `LevelDB#getProperty()`)\n+ it does not support paths, i.e. always returns `:MOCK:`\n\nUse it like so:\n\n```java\nLevelDB.mock();\n```\n\n## Building\n\nProject can be build with ndk-bundle and cmake installed from Android Studio SDK Manager.\n\n## License\n\nThis wrapper library is licensed under the\n[BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause),\nsame as the code from Google.\n\nSee `LICENSE.txt` for the full Copyright.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhf%2Fleveldb-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhf%2Fleveldb-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhf%2Fleveldb-android/lists"}