我在我的應用程序中使用了SQLite數據庫。我想刪除/刪除數據庫,但無法這樣做。我檢查了數據庫的位置並將它存在於/ data/data /org.secure.sms/databases但當我試圖刪除它,它不成功,請幫助我。 這是代碼:在SQLite中刪除數據庫時遇到困難
public static void DeleteDatabase(Context context)
{
try
{
String filePath = context.getFilesDir()+ File.separator + "contactsManager";
String filePath1 = context.getFilesDir()+ File.separator + "database";
String filePath2 = context.getFilesDir()+ File.separator + "databases";
context.deleteDatabase(filePath);
context.deleteDatabase(filePath1);
context.deleteDatabase(filePath2);
File file = new File(filePath);
File file1 = new File(filePath1);
context.deleteFile(file.getName());
context.deleteFile(file1.getName());
}
catch(Exception e)
{
Toast.makeText(context,"Exception in DeleteDatabase",Toast.LENGTH_SHORT).show();
}
}
請幫助me.Thanks提前。
您能否提供錯誤堆棧? –