How to change the location of the database

0

I'm creating a database as SqlOpenHelper and I know it saves the database in the date folder. I would like to know if there is a way to change the location of the database to sdcard for example.

    
asked by anonymous 23.02.2018 / 03:37

1 answer

1

Just pass the complete path (in the SQLiteOpenHelper class) instead of just passing the database name.

abstract class DatabaseManager extends SQLiteOpenHelper {

    private static final String  DATABASE_NAME = "database.db";
    private static final Integer DATABASE_VERSION = 1;

    DatabaseManager(Context context) {
        super(context, Environment.getExternalStorageDirectory()
                + "/Sua-Pasta/" + DATABASE_NAME, null, DATABASE_VERSION);
    }
}
    
23.02.2018 / 04:56