Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

💡 [需求] 希望新增“恢复默认值”功能 #465

Open
Tobapuww opened this issue Oct 24, 2023 · 1 comment
Open

💡 [需求] 希望新增“恢复默认值”功能 #465

Tobapuww opened this issue Oct 24, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@Tobapuww
Copy link

Tobapuww commented Oct 24, 2023

需求内容

急切需要恢复默认值功能,或更改历史记录功能 在软件中调节某些设置后导致桌面异常卡顿,而且还不想每次都Delete userdata

实现思路&截图

我不太会写代码,如有错误请指正 仅供参考。
//`定义默认值
private static final String DEFAULT_SETTING_1 = "default_setting_1";
private static final String DEFAULT_SETTING_2 = "default_setting_2";
// ...

// 在您的软件中存储默认值
private SharedPreferences preferences;

public void onCreate() {
preferences = getSharedPreferences("my_prefs", MODE_PRIVATE);
// 将默认值存储到SharedPreferences中
preferences.edit().putString("setting_1", DEFAULT_SETTING_1).apply();
preferences.edit().putString("setting_2", DEFAULT_SETTING_2).apply();
// ...
}

// 实现恢复默认值的功能
public void resetToDefaults() {
// 获取默认值
String defaultSetting1 = DEFAULT_SETTING_1;
String defaultSetting2 = DEFAULT_SETTING_2;
// ...

// 恢复默认值  
preferences.edit().putString("setting_1", defaultSetting1).apply();  
preferences.edit().putString("setting_2", defaultSetting2).apply();  
// ...  

}

简单例子

在软件中设置根目录,或者子项目中添加恢复默认值,或在根目录中添加更改历史记录 以更方便的恢复问题。

@Tobapuww Tobapuww added the enhancement New feature or request label Oct 24, 2023
@Sevtinge
Copy link
Member

Sevtinge commented Nov 2, 2023

设置-重置模块配置 是不是你想要的

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants