如何保存设置文本?

How to save setText?

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());
        }
    });

我不知道如何保存 getText dhas 的输出 haout 以便下次启动应用程序时使用。

感谢您的帮助!

您可以将其保存在共享首选项中。示例:

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);

有关共享首选项的更多信息here

如果您需要永久保存数据。 尝试保存为 .txt 文件。