Example usage for android.database.sqlite SQLiteOpenHelper getDatabaseName

List of usage examples for android.database.sqlite SQLiteOpenHelper getDatabaseName

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteOpenHelper getDatabaseName.

Prototype

public String getDatabaseName() 

Source Link

Document

Return the name of the SQLite database being opened, as given to the constructor.

Usage

From source file:nodomain.freeyourgadget.gadgetbridge.activities.DbManagementActivity.java

private void importDB() {
    new AlertDialog.Builder(this).setCancelable(true).setTitle(R.string.dbmanagementactivity_import_data_title)
            .setMessage(R.string.dbmanagementactivity_overwrite_database_confirmation)
            .setPositiveButton(R.string.dbmanagementactivity_overwrite, new DialogInterface.OnClickListener() {
                @Override//  w  w  w .  j a v  a2 s  .  co  m
                public void onClick(DialogInterface dialog, int which) {
                    try (DBHandler dbHandler = GBApplication.acquireDB()) {
                        importShared();
                        DBHelper helper = new DBHelper(DbManagementActivity.this);
                        File dir = FileUtils.getExternalFilesDir();
                        SQLiteOpenHelper sqLiteOpenHelper = dbHandler.getHelper();
                        File sourceFile = new File(dir, sqLiteOpenHelper.getDatabaseName());
                        helper.importDB(dbHandler, sourceFile);
                        helper.validateDB(sqLiteOpenHelper);
                        GB.toast(DbManagementActivity.this,
                                getString(R.string.dbmanagementactivity_import_successful), Toast.LENGTH_LONG,
                                GB.INFO);
                    } catch (Exception ex) {
                        GB.toast(DbManagementActivity.this,
                                getString(R.string.dbmanagementactivity_error_importing_db, ex.getMessage()),
                                Toast.LENGTH_LONG, GB.ERROR, ex);
                    }
                }
            }).setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).show();
}