Skip to content

Commit

Permalink
Make DatabaseOperations class open with all its methods
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedGamal92 committed May 22, 2020
1 parent c7f16bc commit eeeb60f
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import androidx.test.platform.app.InstrumentationRegistry
import java.io.File
import java.util.ArrayList

class DatabaseOperations {
open class DatabaseOperations {

fun getAllDatabaseFiles(): List<File> {
open fun getAllDatabaseFiles(): List<File> {
return InstrumentationRegistry.getInstrumentation().targetContext
.let { context ->
context.databaseList()
Expand All @@ -16,14 +16,14 @@ class DatabaseOperations {
}
}

fun openDatabase(databaseFile: File): SQLiteDatabase {
open fun openDatabase(databaseFile: File): SQLiteDatabase {
return SQLiteDatabase.openDatabase(
databaseFile.absolutePath,
null /* cursorFactory */,
0 /* flags */)
}

fun getTableNames(sqLiteDatabase: SQLiteDatabase): List<String> {
open fun getTableNames(sqLiteDatabase: SQLiteDatabase): List<String> {
sqLiteDatabase.rawQuery("SELECT name FROM sqlite_master WHERE type IN (?, ?)", arrayOf("table", "view"))
.use { cursor ->
val tableNames = ArrayList<String>()
Expand All @@ -34,7 +34,7 @@ class DatabaseOperations {
}
}

fun deleteTableContent(sqLiteDatabase: SQLiteDatabase, tableName: String) {
open fun deleteTableContent(sqLiteDatabase: SQLiteDatabase, tableName: String) {
sqLiteDatabase.delete(tableName, null, null)
}
}
}

0 comments on commit eeeb60f

Please sign in to comment.