Skip to content

DPreference is a library that can replace multi_process sharepreference in HMOS.

License

Notifications You must be signed in to change notification settings

Applib-HarmonyOS/Dpreference

Repository files navigation

.github/workflows/main.yml Quality Gate Status

DPreference

A HMOS library for DPreference.

Source

Inspired by Dozen Wang/DPreference

Features

  1. Works multiprocess safely.
  2. Similar API like Preferences.
  3. DPreference is just a wrapper of original Preferences with data Ability.

Dependency

  1. For using dpreference module in sample app, include the source code and add the below dependencies in entry/build.gradle to generate hap/support.har.
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
        implementation project(path: ':dpreference')
        testImplementation 'junit:junit:4.13'
        ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
    }
  1. For using dpreference in separate application using har file, add the har file in the entry/libs folder and add the dependencies in entry/build.gradle file.
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.har'])
        testImplementation 'junit:junit:4.13'
    }
  1. For using dpreference from a remote repository in separate application, add the below dependencies in entry/build.gradle file.
    dependencies {
        implementation 'dev.applibgroup:dpreference:1.0.0'
        testImplementation 'junit:junit:4.13'
    }

Usage

    DPreference dPreference = new DPreference(context, "default");
    dPreference.setPrefString( "key", "value");
    dPreference.getPrefString("key", "defaultValue");

About

DPreference is a library that can replace multi_process sharepreference in HMOS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages