Skip to content

Instantly share code, notes, and snippets.

@ismk
Created March 10, 2017 20:20
Show Gist options
  • Select an option

  • Save ismk/6ab054055f1c439f3ae9363d5e01bee1 to your computer and use it in GitHub Desktop.

Select an option

Save ismk/6ab054055f1c439f3ae9363d5e01bee1 to your computer and use it in GitHub Desktop.
tournament db helper class
public Tournament getOngoingTournament() {
Tournament tournament = null;
SQLiteDatabase db = this.getReadableDatabase();
String sql = "SELECT "
+ COLUMN_TOURNAMENT_ID + ","
+ COLUMN_STATUS + ","
+ COLUMN_FIRST_USER + ","
+ COLUMN_FIRST_PRIZE + ","
+ COLUMN_SECOND_USER + ","
+ COLUMN_SECOND_PRIZE + ","
+ COLUMN_THIRD_USER + ","
+ COLUMN_THIRD_PRIZE + ","
+ COLUMN_ENTRY_FEE + ","
+ COLUMN_HOUSE_PROFIT + " FROM " + TABLE_NAME;
Cursor cursor=db.rawQuery(sql, new String[]{});
if(cursor.getCount()>0) {
cursor.moveToFirst();
tournament = new Tournament(
cursor.getInt(0),
cursor.getString(2),
cursor.getInt(3),
cursor.getString(4),
cursor.getInt(5),
cursor.getString(6),
cursor.getInt(7),
cursor.getInt(8),
cursor.getInt(9),
cursor.getString(1)
);
cursor.close();
}
return tournament;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment