-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDatabaseHelper.java
More file actions
28 lines (21 loc) · 887 Bytes
/
DatabaseHelper.java
File metadata and controls
28 lines (21 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package helper;
import android.content.Context;
import androidx.room.Room;
import androidx.test.platform.app.InstrumentationRegistry;
import java.io.File;
import io.split.android.client.storage.db.SplitRoomDatabase;
public class DatabaseHelper {
public static boolean removeDatabaseFile(String name) {
File databases = new File(InstrumentationRegistry.getInstrumentation().getContext().getApplicationInfo().dataDir + "/databases");
File db = new File(databases, name);
return db.delete();
}
public static SplitRoomDatabase getTestDatabase(Context context) {
SplitRoomDatabase database = Room.inMemoryDatabaseBuilder(context, SplitRoomDatabase.class)
.fallbackToDestructiveMigration()
.allowMainThreadQueries()
.build();
database.clearAllTables();
return database;
}
}