{"id":4148,"url":"https://github.com/sriraman/react-native-shared-preferences","last_synced_at":"2025-08-04T00:32:23.539Z","repository":{"id":47109987,"uuid":"58785065","full_name":"sriraman/react-native-shared-preferences","owner":"sriraman","description":"Android's Native key value storage system in React Native","archived":false,"fork":false,"pushed_at":"2021-09-13T05:59:37.000Z","size":121,"stargazers_count":125,"open_issues_count":8,"forks_count":55,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-28T00:53:12.561Z","etag":null,"topics":["android","react-native","shared-preferences","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sriraman.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}},"created_at":"2016-05-14T02:19:32.000Z","updated_at":"2023-11-22T07:57:09.000Z","dependencies_parsed_at":"2022-09-18T06:15:41.370Z","dependency_job_id":null,"html_url":"https://github.com/sriraman/react-native-shared-preferences","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sriraman/react-native-shared-preferences","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sriraman%2Freact-native-shared-preferences","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sriraman%2Freact-native-shared-preferences/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sriraman%2Freact-native-shared-preferences/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sriraman%2Freact-native-shared-preferences/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sriraman","download_url":"https://codeload.github.com/sriraman/react-native-shared-preferences/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sriraman%2Freact-native-shared-preferences/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268634063,"owners_count":24281895,"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-08-03T02:00:12.545Z","response_time":2577,"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":["android","react-native","shared-preferences","storage"],"created_at":"2024-01-05T20:17:02.574Z","updated_at":"2025-08-04T00:32:22.958Z","avatar_url":"https://github.com/sriraman.png","language":"Java","funding_links":[],"categories":["Components","Java","Others"],"sub_categories":["UI"],"readme":"# React Native Shared Preferences\n\nAndroid's Native key value storage system in React Native\n\n## Installation\n\n### \u003c RN 0.47\n```bash\nnpm install react-native-shared-preferences@0.0.8 --save\n```\n\n### \u003e= RN 0.47\n```bash\nnpm install react-native-shared-preferences --save\n```\n\n## Project setup and initialization\n\n\n* In `android/settings.gradle`\n\n```gradle\n...\ninclude ':react-native-shared-preferences', ':app'\nproject(':react-native-shared-preferences').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-shared-preferences/android')\n```\n\n* In `android/app/build.gradle`\n\n```gradle\n...\ndependencies {\n    /* YOUR DEPENDENCIES HERE */\n    compile \"com.facebook.react:react-native:+\"\n    compile project(\":react-native-shared-preferences\") // \u003c--- add this\n}\n\n```\n\n* Register Module (in MainApplication.java)\n\n```java\nimport in.sriraman.sharedpreferences.RNSharedPreferencesReactPackage;  // \u003c--- import\n\npublic class MainActivity extends ReactActivity {\n  ......\n\n  @Override\n  protected List\u003cReactPackage\u003e getPackages() {\n      return Arrays.\u003cReactPackage\u003easList(\n          new MainReactPackage(),\n          new RNSharedPreferencesReactPackage() // \u003c--- Add this\n      );\n  }\n\n  ......\n\n}\n```\n\n\n## Usage\n\n#### Import\n\n```javascript\nvar SharedPreferences = require('react-native-shared-preferences');\n```\n\n#### Configure name of preferences file. (Optional. Must be called before other functions.)\n\n```javascript\nSharedPreferences.setName(\"name\");\n```\n\n#### Set Item\n\n```javascript\nSharedPreferences.setItem(\"key\",\"value\");\n```\n\n#### Get an value\n\n```javascript\nSharedPreferences.getItem(\"key\", function(value){\n  console.log(value);\n});\n```\n\n#### Get multiple items\n\n```javascript\nSharedPreferences.getItems([\"key1\",\"key2\"], function(values){\n  console.log(values)\n});\n```\n\n#### Get all values\n\n```javascript\nSharedPreferences.getAll(function(values){\n  console.log(values);\n});\n```\n\n#### Clear all values\n\n```javascript\nSharedPreferences.clear();\n```\n\n#### Get all keys - returns promise with array of keys\n```javascript\nSharedPreferences.getAllKeys(function(keys){\n  console.log(keys);\n});\n```\n\n#### Remove Item\n```javascript\nSharedPreferences.removeItem(\"key\");\n```\n\n## Credits\n\n[Sujith Niraikulathan](http://bit.ly/sujithkanna \"Sujith\").\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsriraman%2Freact-native-shared-preferences","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsriraman%2Freact-native-shared-preferences","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsriraman%2Freact-native-shared-preferences/lists"}