这里完美地描述了如何做,唯一的问题:他不知道功能openFileOutput()
;
private void saveSettingsFile() {
String FILENAME = "settings";
String string = "hello world!";
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE); //openFileOutput underlined red
try {
fos.write(string.getBytes());
fos.close();
} catch (IOException e) {
Log.e("Controller", e.getMessage() + e.getLocalizedMessage() + e.getCause());
}
}
这些是我导入的相关包:
import java.io.FileOutputStream;
import java.io.IOException;
import android.content.Context;