-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app/src/main/java/com/hzy/weex/frame/weex/module/prefrence/SharedPreferenceModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.hzy.weex.frame.weex.module.prefrence; | ||
|
||
import android.content.Context; | ||
|
||
import com.blankj.utilcode.util.SPUtils; | ||
import com.taobao.weex.annotation.JSMethod; | ||
import com.taobao.weex.common.WXModule; | ||
|
||
public class SharedPreferenceModule extends WXModule { | ||
|
||
private final SPUtils mSPUtils; | ||
|
||
public SharedPreferenceModule() { | ||
mSPUtils = SPUtils.getInstance("wxPreference", Context.MODE_PRIVATE); | ||
} | ||
|
||
@JSMethod | ||
@SuppressWarnings("unused") | ||
public void put(String key, String value) { | ||
mSPUtils.put(key, value); | ||
} | ||
|
||
@JSMethod | ||
@SuppressWarnings("unused") | ||
public String get(String key) { | ||
return mSPUtils.getString(key); | ||
} | ||
|
||
@JSMethod | ||
@SuppressWarnings("unused") | ||
public void clear() { | ||
mSPUtils.clear(); | ||
} | ||
|
||
@JSMethod | ||
@SuppressWarnings("unused") | ||
public void remove(String key) { | ||
mSPUtils.remove(key); | ||
} | ||
} |