Example usage for android.content ContextWrapper getDatabasePath

List of usage examples for android.content ContextWrapper getDatabasePath

Introduction

In this page you can find the example usage for android.content ContextWrapper getDatabasePath.

Prototype

@Override
    public File getDatabasePath(String name) 

Source Link

Usage

From source file:Main.java

private static boolean doesDatabaseExist(ContextWrapper context, String dbName) {
    File dbFile = context.getDatabasePath(dbName);
    return dbFile.exists();
}

From source file:Main.java

public static void setupDatabase(Context context, String db_name) {
    ContextWrapper cw = new ContextWrapper(context);
    String db_path = cw.getDatabasePath(db_name).getPath();

    try {//from w  w w .  j a  v a 2s. co m
        // Setup
        byte[] buffer = new byte[1024];
        int length;
        InputStream myInput = context.getAssets().open(db_name);
        OutputStream myOutput = new FileOutputStream(db_path);

        // Write all the things.
        while ((length = myInput.read(buffer)) > 0)
            myOutput.write(buffer, 0, length);

        // Cleanup
        myOutput.close();
        myOutput.flush();
        myInput.close();
    } catch (IOException e) {
        // You done goofed.
        e.printStackTrace();
    }
}

From source file:com.velli.passwordmanager.ActivityLockScreen.java

private static boolean doesDatabaseExist(ContextWrapper context, String dbName) {
    final File dbFile = context.getDatabasePath(dbName);
    return dbFile.exists();
}