package external;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.apache.http.util.EncodingUtils;
import android.content.SharedPreferences;
public class write_read {
public void writeFileData(String fileName, String message) {
try {
FileOutputStream fout = openFileOutput(fileName, MODE_PRIVATE); //MODE_PRIVATE cannot be resolved to a variable
byte[] bytes = message.getBytes();
fout.write(bytes);
fout.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
在自己写的类里面不能调用这个函数吗?openFileOutput?
真是莫名其妙!
------解决方案--------------------
写文件难道不是FileInputStream????
------解决方案--------------------
//MODE_PRIVATE cannot be resolved to a variable
注意openFileOutput 是Context的方法,如果你不是Activity就不能直接调用,而且MODE_PRIVATE要改为Context.MODE_PRIVATE