# react-native-rnpreferencesutils

> A package for working with native shared preferences

Latest version **1.1.0** (published 2019-10-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-native-rnpreferencesutils
pnpm add react-native-rnpreferencesutils
yarn add react-native-rnpreferencesutils
bun add react-native-rnpreferencesutils
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2019-10-01 |
| First published | 2019-02-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 27.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | vv0z |
| Maintainers | ibeshkar |
| Keywords | react-native, android, sharedpreferences, save, retrieve |

## Links

- npm: https://www.npmjs.com/package/react-native-rnpreferencesutils
- Repository: https://github.com/ibeshkar/RNSharedPreference
- Homepage: https://github.com/ibeshkar/RNSharedPreference#readme
- Issues: https://github.com/ibeshkar/RNSharedPreference/issues
- npm.io page: https://npm.io/package/react-native-rnpreferencesutils

## Dependencies (2)

- [react](https://npm.io/package/react.md) 16.3.1
- [react-native](https://npm.io/package/react-native.md) 0.55.4

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2019-10-01
- 1.0.1 — 2019-02-27
- 1.0.0 — 2019-02-27

## README

# RNSharedPreferences

 A package for working with native shared preferences

# Overview

 This package provides a lot of function for save and retrieve data from shared preference.
 By this package save and retrieve string,boolean,float,long and List values.

## Installation

### < RN 0.47
```bash
npm install react-native-rnpreferencesutils@1.1.0 --save
```

### >= RN 0.47
```bash
npm install react-native-rnpreferencesutils --save
```

## Project setup and initialization


* In `android/settings.gradle`

```gradle
...
include ':react-native-rnpreferencesutils', ':app'
project(':react-native-rnpreferencesutils').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-rnpreferencesutils/android')
```

* In `android/app/build.gradle`

```gradle
...
dependencies {
    compile "com.facebook.react:react-native:+"
    compile project(":react-native-rnpreferencesutils") // <--- add this
}

```

* Register Module (in MainApplication.java)

```java
import com.rnpreferenceutil.PreferencePackage;;  // <--- import

public class MainActivity extends ReactActivity {
  ......

  @Override
  protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new PreferencePackage() // <--- Add this
      );
  }

  ......

}
```


## Usage

#### Import

```javascript
import RNPrefs from "react-native-rnpreferencesutils";
```

#### Save string

```javascript
RNPrefs.saveString("key","value");
```

#### Retrieve string value

```javascript
RNPrefs.getString('key').then(value => {
  console.log(value);
});
```

#### Save boolean

```javascript
RNPrefs.saveBoolean("key","value");
```

#### Retrieve boolean value

```javascript
RNPrefs.getBoolean('key').then(value => {
  console.log(value);
});
```

#### Save StringSet

```javascript
RNPrefs.saveStringSet("key","value");
```

#### Retrieve StringSet value

```javascript
RNPrefs.getStringSet('key').then(value => {
  console.log(value);
});
```

.
.
.

#### Clear all values

```javascript
RNPrefs.clearAll();
```

#### Remove Item

```javascript
RNPrefs.remove("key");
```

---
_Source: https://npm.io/package/react-native-rnpreferencesutils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
