1
我試圖從內部存儲清除我的應用程序的所有數據,問題是它在模擬器上工作。我可以刪除所有文件,將所有共享首選項設置爲默認和刪除數據庫,但是當我重置應用程序後在我的手機(HTC EVO 3D)上運行我時,從Web服務器收到的圖像不會合並。只有這樣才能發生的事情是,如果我已經將它們放在我的數據庫中了......這非常奇怪,因爲我已經刪除了數據庫和所有其他文件。下面是我使用的代碼:android刪除應用程序數據奇怪的問題
//Delete sqlite files :
boolean dbFile = deleteDatabase("stampii_sys_tpl.sqlite");
Log.e("","deleted : "+dbFile);
String cache = this.getCacheDir().toString();
Log.e("","dbPath : "+cache);
File ChFolder = new File(cache);
boolean cachee = deleteDirectory(ChFolder);
Log.e("","Database Folder Delete Success : "+cachee);
// Delete Databases Folder :
String dbPath = "/data/data/"+this.getPackageName()+"/databases/";
Log.e("","dbPath : "+dbPath);
File dbFolder = new File(dbPath);
boolean dbFold = deleteDirectory(dbFolder);
Log.e("","Database Folder Delete Success : "+dbFold);
// Delete Files Folder :
String name = this.getFilesDir().toString();
Log.e("","path : "+name);
File files = new File(name);
boolean filesFol = deleteDirectory(files);
Log.e("","filesFol : "+filesFol);
// Clear Shared Preferences :
editor.putBoolean("resetApp", false);
editor.putBoolean("isLoggedIn", false);
editor.putInt("storagePath", 0);
editor.putInt("lastUser", 0);
editor.putBoolean("getInfoFromJsonForColl", true);
editor.commit();
static public boolean deleteDirectory(File path) {
if(path.exists()) {
File[] files = path.listFiles();
if (files == null) {
return true;
}
for(int i=0; i<files.length; i++) {
if(files[i].isDirectory()) {
deleteDirectory(files[i]);
}
else {
files[i].delete();
}
}
}
return(path.delete());
}
所以我的問題是...難道我做錯了什麼,如果有保持某種程度上的應用程序的數據庫緩存或類似的Android的可能性即使原始文件被刪除。
在此先感謝!