我試圖使用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