0
我一直在嘗試將前一天左右的文件創建到iPhone應用程序的文檔目錄中。通常,如果我是在Objective-C這樣做,我會用如何使用XMLVM訪問iPhone應用程序Documents文件夾
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
,我需要這個目錄的訪問的原因是爲了保存plist文件中的一些應用程序設置(即不應該改變,當應用程序需要更新)。
我一直在正常的.app目錄中存儲文件,但從那裏我不能覆蓋文件,當我嘗試保存一些新的設置。
這裏是我使用要刪除的文件
public static Boolean DeleteSettingsFile(){
File f = new File(settingsFile);
if(f.exists())
if(f.delete())
return true;
return false;
}
試圖刪除NSBundle.mainBundle()的文件時,這不工作的代碼。bundlePath()文件夾
我也得到使用此代碼的結果相同
public static Boolean SaveSettingsFile(String s){
File f = new File(settingsFile);
try {
if(f.createNewFile())
if(NSData.dataWithBytes(s.getBytes()).writeToFile(settingsFile, true))
return true;
}
catch (Exception e){
System.err.println(e.getMessage());
}
return false;
}
這將創建文件,但是一旦它在那裏,我只能讀取其內容。
任何幫助,將不勝感激