我试图使用openFileOutput函数,但它不想编译...不认识de函数。我使用android sdk 1.6。这是一个sdk问题吗?这是一个参数问题吗?android openFileOutput有什么问题?
import java.io.FileOutputStream;
public static void save(String filename, MyObjectClassArray[] theObjectAr) {
FileOutputStream fos;
try {
fos = openFileOutput(filename, Context.MODE_PRIVATE);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(theObjectAr);
oos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
}
谢谢,就是这样。 – Fabien 2010-09-02 10:06:27
我无法得到这个工作。我在这里为ctx尝试了一个传递的上下文,context.getApplicationContext(),Application.instance()和Application.instance()。getApplicationContext(),它总是抛出FileNotFoundException异常。 – 2011-05-23 08:16:28
原来,我有一个权限问题。绝对不明显的是,“权限被拒绝”问题导致了“FileNotFoundException”。 – 2011-05-23 21:24:36