这是完美的描述here如何做到这一点,唯一的问题:他不知道的功能openFileOutput()
;Android:如何在内部存储器上存储数据?
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;
你能分享logcat的误差输出一活动的内? – 2010-09-02 14:35:44
我只注意到“openFileOutput”是加下划线的红色。 Eclipse要求我在我的课堂上创建一个所谓的方法,我无意中这样做了。现在我删除了这个方法存根,并且“openFileOutput”再次被强调为红色。 – OneWorld 2010-09-02 14:44:16
@Konstantin:它比逻辑问题更为合理。所以logcat还没有帮助。知道我甚至不能编译它。 – OneWorld 2010-09-02 14:51:13