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.
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.
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);
}
}