{"id":31480755,"url":"https://github.com/bh90210/simpledbw","last_synced_at":"2026-04-13T20:32:10.118Z","repository":{"id":110330010,"uuid":"187630944","full_name":"bh90210/SimpleDBW","owner":"bh90210","description":"(proof of concept) Persistent (key/value) storage library for Android (Badger binding)","archived":false,"fork":false,"pushed_at":"2019-06-08T14:58:20.000Z","size":259972,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-02T05:52:51.167Z","etag":null,"topics":["android","badger","badgerdb","go","java","key-value","library","persistent-storage","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bh90210.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-20T11:53:25.000Z","updated_at":"2024-02-04T22:19:53.000Z","dependencies_parsed_at":"2023-03-17T13:31:10.314Z","dependency_job_id":null,"html_url":"https://github.com/bh90210/SimpleDBW","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/bh90210/SimpleDBW","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bh90210%2FSimpleDBW","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bh90210%2FSimpleDBW/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bh90210%2FSimpleDBW/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bh90210%2FSimpleDBW/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bh90210","download_url":"https://codeload.github.com/bh90210/SimpleDBW/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bh90210%2FSimpleDBW/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31770718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T20:17:16.280Z","status":"ssl_error","status_checked_at":"2026-04-13T20:17:08.216Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["android","badger","badgerdb","go","java","key-value","library","persistent-storage","wrapper"],"created_at":"2025-10-02T05:50:13.508Z","updated_at":"2026-04-13T20:32:10.086Z","avatar_url":"https://github.com/bh90210.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimpleDBW\nA simple to use persistente storage wrapper around [Badger](https://github.com/dgraph-io/badger) for Android.\n\n![usage preview](https://media.giphy.com/media/QygXWDXt26asEEAe0V/giphy.gif)\n\n### Installation\nDownload (or clone) the repository then use Android Studio to import the library to your project `file \u003e new \u003e import module`\n\nIn your app's module `build.gradle` file include\n```gradle\nrepositories {\n    flatDir {\n        dirs './simpledbw/libs'\n    }\n}\n```\n\nThe library uses lifecycle-extensions. So you have to also include this dependacy.\n```gradle\ndependencies {\n   implementation \"androidx.lifecycle:lifecycle-extensions:2.0.0\"\n   implementation (name:'simpledbw')\n}\n```\n#### initialisation \nIn your module's main activity onCreate function add this line\n\n```java\nProcessLifecycleOwner.get().getLifecycle().addObserver(new DBWhelper());\n```\n\nie.\n```java\npublic class MainActivity extends AppCompatActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        // DB init\n        // Add Lifecycle Observer\n        ProcessLifecycleOwner.get().getLifecycle().addObserver(new DBWhelper());\n```\n\n### Usage\n\n#### Set value\n\n```java\nDatabase db = new Database();\n```\n\nThe database uses byte[] for both keys and values.\n\n```java\ndb.Update(\"key\".getBytes(), \"value\".getBytes());\n```\n\n#### Get value\n\nA db.View query returns a byte[] with the requested value. If key does not exist it returns \"key does not exist\".\n\n```java\nbyte[] returnedvalue = db.View(\"key\".getBytes());\n```\n\nThis can be for example converted to string and used with TextView like so\n\n```java\nString text = new String(returnedvalue);\nexampleTextView.setText(text);\n```\n\n#### Delete key\n\n```java\ndb.Delete(\"key\".getBytes());\n```\n\n#### Iterate\n\n##### Prefix\n\nIterated over the database quering a specific prefix\n\n```java\nArrayMap\u003cbyte[], byte[]\u003e entries =  db.ViewPrefix(\"prefix\".getBytes());\n```\n\nand you get an ArrayMap with all the associated keys and values. Please check Android's [documentation](https://developer.android.com/reference/android/support/v4/util/ArrayMap) for more information and usage.\n\nDelete all keys assosiated with spedific prefix.\n\n```java\ndb.PrefixDrop(\"prefix\".getBytes());\n```\n                \n\n##### Dump returns an ArrayMap with every entry in the database.\n\n```java\nArrayMap\u003cbyte[], byte[]\u003e entries =  db.DumpAll();\n```\n\nit can be used for example to inflate a TableLayout\n\nie. \n```java\nArrayMap\u003cbyte[], byte[]\u003e tables =  db.DumpAll();\nTableLayout dump = findViewById(R.id.ret_vals);\ndump.removeAllViews();\nIterator it = tables.entrySet().iterator();\n\nwhile (it.hasNext()) {\n  ArrayMap.Entry pair = (ArrayMap.Entry)it.next();\n  LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService\n                            (Context.LAYOUT_INFLATER_SERVICE);\n  View row = inflater.inflate(R.layout.row, null);\n                    dump.addView(row);\n   //View rowID = row.findViewById(R.id.tableraw);\n   TextView keyfield = row.findViewById(R.id.printkey);\n   TextView valuefield = row.findViewById(R.id.printvalue);\n   String key = new String((byte[]) pair.getKey());\n   String value = new String((byte[]) pair.getValue());\n   keyfield.setText(key);\n   valuefield.setText(value);\n    it.remove(); // avoids a ConcurrentModificationException\n}\n```         \n\n#### Monotonically increasing integers\n\nYou can get monotonically increasing integers with strong durability\n\n```java\nlong nextInt = db.Mii(\"monotonic_key\".getBytes());\n```\n\nReset the count by deleting the key\n```java\ndb.Delete(\"monotonic_key\".getBytes());\n```\n\n#### Drop all\n```java\ndb.DropDB();\n```\n\n#### Pre-populated entries\n\nPlace this on your module's main activity onCreate function. Please note if you drop the DB or delete the key the next time the app starts and opens the database these keys *will* regenerate.\n\n```java\ndb.PrePopulate(\"PREFIX_sample\".getBytes(), \"sample_value\".getBytes());\n```\n\nie. \n```java\npublic class MainActivity extends AppCompatActivity {\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        // DB init\n        // Add Lifecycle Observer\n        ProcessLifecycleOwner.get().getLifecycle().addObserver(new DBWhelper());\n        // call the class\n        Database db = new Database();\n        // add some dummy pre-populated values\n        db.PrePopulate(\"PREFIX_sample\".getBytes(), \"sample_value\".getBytes());\n        db.PrePopulate(\"PREFIX_dummy\".getBytes(), \"dummy_value\".getBytes());\n```\n\n### Build Go source\n\nUnfortunatly gomobile does not support gomodules at the moment so you have to work within $GOPATH.\n\nFirst ensure you have gomobile and badger installed. For more information click [here](https://godoc.org/golang.org/x/mobile/cmd/gomobile) and [here](https://github.com/dgraph-io/badger) respectively.\n\n* ```go get github.com/dgraph-io/badger/...```\n\nand\n\n* ```go get golang.org/x/mobile/cmd/gomobile```\n* ```gomobile init```\n\nthen\n\n* run ```go get https://github.com/bh90210/SimpleDBW``` \n* and ```gomobile bind -o simpledbw/dbwrapper.aar -target=android $GOPATH/src/github.com/bh90210/SimpleDBW``` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbh90210%2Fsimpledbw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbh90210%2Fsimpledbw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbh90210%2Fsimpledbw/lists"}