A HMOS library for DPreference.
Inspired by Dozen Wang/DPreference
- Works multiprocess safely.
- Similar API like Preferences.
- DPreference is just a wrapper of original Preferences with data Ability.
- 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'
}
- 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'
}
- 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'
}
DPreference dPreference = new DPreference(context, "default");
dPreference.setPrefString( "key", "value");
dPreference.getPrefString("key", "defaultValue");