mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-11 11:33:09 +02:00
Updated AndroidX
This commit is contained in:
@@ -248,18 +248,16 @@ class SQLiteCopyOpenHelper implements SupportSQLiteOpenHelper, DelegatingOpenHel
|
||||
}
|
||||
|
||||
private SupportSQLiteOpenHelper createFrameworkOpenHelper(File databaseFile) {
|
||||
String databaseName = databaseFile.getName();
|
||||
int version;
|
||||
final int version;
|
||||
try {
|
||||
version = DBUtil.readVersion(databaseFile);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Malformed database file, unable to read version.", e);
|
||||
}
|
||||
|
||||
FrameworkSQLiteOpenHelperFactory factory = new FrameworkSQLiteOpenHelperFactory();
|
||||
Configuration configuration = Configuration.builder(mContext)
|
||||
.name(databaseName)
|
||||
.callback(new Callback(version) {
|
||||
.name(databaseFile.getAbsolutePath())
|
||||
.callback(new Callback(Math.max(version, 1)) {
|
||||
@Override
|
||||
public void onCreate(@NonNull SupportSQLiteDatabase db) {
|
||||
}
|
||||
@@ -268,6 +266,18 @@ class SQLiteCopyOpenHelper implements SupportSQLiteOpenHelper, DelegatingOpenHel
|
||||
public void onUpgrade(@NonNull SupportSQLiteDatabase db, int oldVersion,
|
||||
int newVersion) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen(@NonNull SupportSQLiteDatabase db) {
|
||||
// If pre-packaged database has a version < 1 we will open it as if it was
|
||||
// version 1 because the framework open helper does not allow version < 1.
|
||||
// The database will be considered as newly created and onCreate() will be
|
||||
// invoked, but we do nothing and reset the version back so Room later runs
|
||||
// migrations as usual.
|
||||
if (version < 1) {
|
||||
db.setVersion(version);
|
||||
}
|
||||
}
|
||||
})
|
||||
.build();
|
||||
return factory.create(configuration);
|
||||
|
||||
Reference in New Issue
Block a user