delete Database File - Android Database

Android examples for Database:Database File

Description

delete Database File

Demo Code


import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

public class Main{
    /*  w w w.j av a 2  s .com*/
    public static boolean deleteDatabase(Context context) {
        String fullPath = "your path";
        File file = new File(fullPath);
        if (file != null && file.exists()) {
            File[] files = file.listFiles();
            for (int i = 0; files != null && i < files.length; i++) {
                File subFile = files[i];
                if (subFile != null && subFile.exists()) {
                    subFile.delete();
                }
            }
            boolean result = file.delete();
            return result;
        }
        return false;
    }
}

Related Tutorials