chengxuncc / fileprefs

A file based SharedPreferences library for android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FileSharedPreferences


A file based SharedPreferences library for android, which working great on Android SDK>=24 (Android 7.0 Nougat).

Usage

Add JitPack repository to project build file:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency:

dependencies {
    implementation 'com.github.chengxuncc:fileprefs:1.0'
}

Set app sharedPreferences file to be world readable:

SharedPreferences sharedpreferences = getSharedPreferences(YourPreferencesFileName, MODE_PRIVATE);
// you should use makeWorldReadable every time after using commit() or apply(), however apply() will delay, it may be better to use commit()
FileSharedPreferences.makeWorldReadable(YourPackageName,YourPreferencesFileName);

Using FileSharedPreferences at other apps or your xposed module hook method:

FileSharedPreferences sharedPreferences = new FileSharedPreferences(YourPackageName, YourPreferencesFileName);
// if you want to reload
sharedPreferences.reload();

Credit

XSharedPreferences

About

A file based SharedPreferences library for android.

License:Apache License 2.0


Languages

Language:Java 100.0%