Example usage for android.database.sqlite SQLiteDatabase getPath

List of usage examples for android.database.sqlite SQLiteDatabase getPath

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteDatabase getPath.

Prototype

public final String getPath() 

Source Link

Document

Gets the path to the database file.

Usage

From source file:edu.mit.media.funf.pipeline.BasicPipeline.java

protected void runArchive() {

    SQLiteDatabase db = databaseHelper.getWritableDatabase();
    // TODO: add check to make sure this is not empty
    File dbFile = new File(db.getPath());
    db.close();/*from  w  w  w.j  a v a  2 s  .c om*/
    if (archive.add(dbFile)) {
        dbFile.delete();
    }
    reloadDbHelper(manager);
    db = databaseHelper.getWritableDatabase(); // Build new database
    db.close();
}

From source file:com.money.manager.ex.database.MmxOpenHelper.java

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    Timber.d("Upgrading from %1$d  to %2$d", oldVersion, newVersion);

    try {/*from w w  w  .  java 2 s .c  om*/
        String currentDbFile = db.getPath();
        createDatabaseBackupOnUpgrade(currentDbFile, oldVersion);
    } catch (Exception ex) {
        Timber.e(ex, "creating database backup, can't continue");

        // don't upgrade
        return;
    }

    // update databases
    updateDatabase(db, oldVersion, newVersion);

    // notify sync about the db update.
    new SyncManager(getContext()).dataChanged();
}