{"id":18014623,"url":"https://github.com/achep/config","last_synced_at":"2025-03-26T18:30:42.871Z","repository":{"id":146978467,"uuid":"139670954","full_name":"AChep/config","owner":"AChep","description":"Utility library for Android with Kotlin to help you to create and manage simple _settings_ of an application.","archived":false,"fork":false,"pushed_at":"2020-11-04T18:22:45.000Z","size":237,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T06:04:13.863Z","etag":null,"topics":["android","kotlin","sharedpreferences"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/AChep.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-04T05:09:57.000Z","updated_at":"2023-09-08T17:42:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"96eee219-9c4e-429e-9f58-b62a4227061d","html_url":"https://github.com/AChep/config","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AChep%2Fconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AChep%2Fconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AChep%2Fconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AChep%2Fconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AChep","download_url":"https://codeload.github.com/AChep/config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245712475,"owners_count":20660246,"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","kotlin","sharedpreferences"],"created_at":"2024-10-30T04:10:24.296Z","updated_at":"2025-03-26T18:30:42.856Z","avatar_url":"https://github.com/AChep.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# config\n\nNote: The tool is fine for small projects, but for bigger ones I would recommend using the Datastore library wrapped with your own layer of abstraction, or https://github.com/tfcporciuncula/flow-preferences if you use coroutines heavily.\n\n[![Download](https://api.bintray.com/packages/achep/maven/config/images/download.svg)](https://bintray.com/achep/maven/config/_latestVersion) [![Build Status](https://travis-ci.org/AChep/config.svg?branch=master)](https://travis-ci.org/AChep/config) [![Code Climate](https://codeclimate.com/github/AChep/config/badges/gpa.svg)](https://codeclimate.com/github/AChep/config) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/452d8fe2a0914967b6b65afea5040928)](https://www.codacy.com/app/AChep/config?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=AChep/config\u0026amp;utm_campaign=Badge_Grade)\n\nUtility library for Android with Kotlin to help you to create and manage simple settings of application. \n\nDownload\n----------------\nGradle:\n```groovy\nrepositories {\n  jcenter()\n}\n\ndependencies {\n  implementation 'com.artemchep.config:config:${latestVersion}'\n}\n```\n\nHow to use\n----------------\nFirstly, create your configuration class based on `Config`, for example:\n``` kotlin\nobject Cfg : SharedPrefConfig(\"cfg\") {  \n    const val KEY_INT = \"my_int_key\"  \n    const val KEY_STRING = \"my_string_key\"  \n  \n    var intProperty by configDelegate(KEY_INT, 0)\n      \n    var stringProperty by configDelegate(KEY_STRING, \"\")  \n}\n```\nThen, init it on application create:\n``` kotlin\nclass App : Application() {  \n    override fun onCreate() {  \n        super.onCreate()  \n        Cfg.init(this) // loads all variables from shared preferences \n    }  \n}\n```\nThat's all!  \n\n#### Read value\n``` kotlin\nval value = Cfg.intProperty + 1\n```\nPlease note that getting a value will not actually update it from the `SharedPreferences`, it returns last set value. \n\n#### Write value\n``` kotlin\nCfg.edit(context) { \n    Cfg.intProperty = 100\n    Cfg.stringProperty = \"\"\n}\n```\n\n#### Observe changes\n``` kotlin\nval observer = object : Config.OnConfigChangedListener\u003cString\u003e {\n    override fun onConfigChanged(keys: Set\u003cString\u003e) {\n        // Check if the keys include your \n        // key and update something.\n    }\n}\n\nval registration = Cfg.observe(observer)\n// Do not forget to unregister it later on\n// by calling:\n// Cfg.removeObserver(observer)\n//\n// or via the created Registration instance:\n// registration.unregister()\n```\n\n#### Sample project\nYou may want to check a [sample project][4] for a working example.\n\nRestrictions\n----------------\n1. Property can not be `null`.\n\nReport a bug or request a feature\n----------------\nBefore creating a new issue please make sure that same or similar issue is not already created by checking [open issues][2] and [closed issues][3] *(please note that there might be multiple pages)*. If your issue is already there, don't create a new one, but leave a comment under already existing one.\n\nChecklist for creating issues:\n\n- Keep titles short but descriptive.\n- For feature requests leave a clear description about the feature with examples where appropriate.\n- For bug reports leave as much information as possible about your device, android version, etc.\n- For bug reports also write steps to reproduce the issue.\n\n[Create new issue][1]\n\nVersioning\n----------------\nFor transparency in a release cycle and in striving to maintain backward compatibility, a project should be maintained under the Semantic Versioning guidelines. Sometimes we screw up, but we should adhere to these rules whenever possible.\n\nReleases will be numbered with the following format: `\u003cmajor\u003e.\u003cminor\u003e.\u003cpatch\u003e` and constructed with the following guidelines:\n- Breaking backward compatibility bumps the major while resetting minor and patch\n- New additions without breaking backward compatibility bumps the minor while resetting the patch\n- Bug fixes and misc changes bumps only the patch\n\nFor more information on SemVer, please visit http://semver.org/.\n\nBuild\n----------------\nClone the project and come in:\n\n``` bash\n$ git clone git://github.com/AChep/config.git\n$ cd config/\n```\n\n[1]: https://github.com/AChep/config/issues/new\n[2]: https://github.com/AChep/config/issues?state=open\n[3]: https://github.com/AChep/config/issues?state=closed\n[4]: https://github.com/AChep/config/tree/master/sample\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fachep%2Fconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fachep%2Fconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fachep%2Fconfig/lists"}