Code example for SQLiteDatabase

Methods: getPath

0
        onResetDatabase(db);
    } 
 
    @Override 
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.d(TAG, "onUpgrade() from " + oldVersion + " to " + newVersion);
 
        // make a backup of the database file 
        if (AndroidUtils.isExtStorageAvailable()) { 
            File dbFile = new File(db.getPath());
            File exportDir = new File(Environment.getExternalStorageDirectory(),
                    "seriesguidebackup"); 
            exportDir.mkdirs();
            File file = new File(exportDir, dbFile.getName() + "_b4upgr.db");
 
            try { 
                file.createNewFile();
                AndroidUtils.copyFile(dbFile, file);
            } catch (IOException e) {
                Log.e(TAG, e.getMessage(), e);
            }