Skip to content

Commit

Permalink
Refactor truncate table in IndicatorQuery and Indicator Repository cl…
Browse files Browse the repository at this point in the history
…asses
  • Loading branch information
allan-on committed Jun 14, 2019
1 parent a12729d commit 17ea23f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,7 @@ public void truncateTable() {
public void truncateTable(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + INDICATOR_QUERY_TABLE);
sqLiteDatabase.execSQL(CREATE_TABLE_INDICATOR_QUERY);
Cursor cursor = sqLiteDatabase.rawQuery("SELECT COUNT(*) FROM sqlite_sequence WHERE name = '" + INDICATOR_QUERY_TABLE + "'", null);
cursor.moveToFirst();
int rowCount = cursor.getCount();
if (rowCount > 0) {
sqLiteDatabase.rawQuery("DELETE FROM sqlite_sequence WHERE name = '" + INDICATOR_QUERY_TABLE + "'", null);
}
cursor.close();
sqLiteDatabase.delete("sqlite_sequence", "name = ?", new String[]{INDICATOR_QUERY_TABLE});
}

public Map<String, String> getAllIndicatorQueries() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,7 @@ public void truncateTable() {
public void truncateTable(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + INDICATOR_TABLE);
sqLiteDatabase.execSQL(CREATE_TABLE_INDICATOR);
Cursor cursor = sqLiteDatabase.rawQuery("SELECT COUNT(*) FROM sqlite_sequence WHERE name = '" + INDICATOR_TABLE + "'", null);
cursor.moveToFirst();
int rowCount = cursor.getCount();
if (rowCount > 0) {
sqLiteDatabase.rawQuery("DELETE FROM sqlite_sequence WHERE name = '" + INDICATOR_TABLE + "'", null);
}
cursor.close();
sqLiteDatabase.delete("sqlite_sequence", "name = ?", new String[]{INDICATOR_TABLE});
}

public ReportIndicator getIndicatorByCode(String code) {
Expand Down

0 comments on commit 17ea23f

Please sign in to comment.