final Button haa = (Button) findViewById(R.id.haactiv);
haa.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
dhas = (EditText) findViewById(R.id.dha);
haout = (TextView) findViewById(R.id.haoutput);
haout.setText(dhas.getText());
}
});我不知道如何在下次启动应用程序时将输出haout从getText dhas中保存下来。
谢谢你帮忙!
发布于 2016-01-21 21:24:22
您可以将其保存在共享首选项中。示例:
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putInt(getString(R.string.saved_high_score), newHighScore);
editor.commit();从共享首选项中读取:
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
int defaultValue = getResources().getInteger(R.string.saved_high_score_default);
long highScore = sharedPref.getInt(getString(R.string.saved_high_score), defaultValue);有关共享首选项这里的更多信息
发布于 2016-01-21 23:42:15
如果您需要保存数据永久。尝试保存在.txt文件中。
https://stackoverflow.com/questions/34934566
复制相似问题