gt:         while (!cursor.isAfterLast()) {
context: package org.fossasia.openevent.dbutils;
  
  import android.database.Cursor;
  import android.database.DatabaseUtils;
  import android.database.sqlite.SQLiteDatabase;
  
  import org.fossasia.openevent.data.Event;
  import org.fossasia.openevent.data.Session;
  import org.fossasia.openevent.data.Speaker;
  import org.fossasia.openevent.data.Sponsor;
  import org.fossasia.openevent.data.Version;
  import org.fossasia.openevent.data.parsingExtras.Microlocation;
  import org.fossasia.openevent.data.parsingExtras.Track;
  
  import java.text.ParseException;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Locale;
  
  import timber.log.Timber;
  
  /**
   * Created by MananWason on 24-06-2015.
   */
  public class DatabaseOperations {
      private static final String ASCENDING = " ASC";
  
      private static final String DESCENDING = " DESC";
  
      private static final String SELECT_ALL = "SELECT * FROM ";
  
      private static final String WHERE = " WHERE ";
  
      private static final String EQUAL = " == ";
  
      private static final String LIKE = " LIKE ";
  
      private static final String ORDERBY = " ORDER BY ";
  
      Event event;
  
      public ArrayList<Session> getSessionList(SQLiteDatabase mDb) {
  
          String sortOrder = DbContract.Sessions.ID + ASCENDING;
          Cursor cur = mDb.query(
                  DbContract.Sessions.TABLE_NAME,
                  DbContract.Sessions.FULL_PROJECTION,
                  null,
                  null,
                  null,
                  null,
                  sortOrder
          );
  
          ArrayList<Session> sessions = new ArrayList<>();
          Session s;
  
          cur.moveToFirst();
          while (!cur.isAfterLast()) {
              try {
                  int microlocationId = cur.getInt(cur.getColumnIndex(DbContract.Sessions.MICROLOCATION));
                  Microlocation microlocation = new Microlocation(microlocationId, getMicroLocationById(microlocationId, mDb).getName());
                  int trackId = cur.getInt(cur.getColumnIndex(DbContract.Sessions.TRACK));
                  Track track = new Track(trackId, getTracksbyTracksId(trackId, mDb).getName());
  
                  s = new Session(
                          cur.getInt(cur.getColumnIndex(DbContract.Sessions.ID)),
                          cur.getString(cur.getColumnIndex(DbContract.Sessions.TITLE)),
                          cur.getString(cur.getColumnIndex(DbContract.Sessions.SUBTITLE)),
                          cur.getString(cur.getColumnIndex(DbContract.Sessions.SUMMARY)),
                          cur.getString(cur.getColumnIndex(DbContract.Sessions.DESCRIPTION)),
                          cur.getString(cur.getColumnIndex(DbContract.Sessions.START_TIME)),
                          cur.getString(cur.getColumnIndex(DbContract.Sessions.END_TIME)),
                          cur.getString(cur.getColumnIndex(DbContract.Sessions.START_DATE)),
                          cur.getString(cur.getColumnIndex(DbContract.Sessions.TYPE)),
                          track,
                          cur.getString(cur.getColumnIndex(DbContract.Sessions.LEVEL)),
                          microlocation
  
                  );
                  sessions.add(s);
              } catch (ParseException e) {
                  Timber.e("Parsing Error Occurred at DatabaseOperations::getSessionList.");
              }
              cur.moveToNext();
          }
          cur.close();
          return sessions;
      }
  
      public Session getSessionById(int id, SQLiteDatabase mDb) {
          String selection = DbContract.Sessions.ID + EQUAL + id;
          Cursor cursor = mDb.query(
                  DbContract.Sessions.TABLE_NAME,
                  DbContract.Sessions.FULL_PROJECTION,
                  selection,
                  null,
                  null,
                  null,
                  null
          );
          Session session = null;
          cursor.moveToFirst();
          //Should return only one due to UNIQUE constraint
          try {
              int microlocationId = cursor.getInt(cursor.getColumnIndex(DbContract.Sessions.MICROLOCATION));
              Microlocation microlocation = new Microlocation(microlocationId, getMicroLocationById(microlocationId, mDb).getName());
              int trackId = cursor.getInt(cursor.getColumnIndex(DbContract.Sessions.TRACK));
              Track track = new Track(trackId, getTracksbyTracksId(trackId, mDb).getName());
  
              session = new Session(
                      cursor.getInt(cursor.getColumnIndex(DbContract.Sessions.ID)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Sessions.TITLE)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Sessions.SUBTITLE)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Sessions.SUMMARY)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Sessions.DESCRIPTION)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Sessions.START_TIME)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Sessions.END_TIME)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Sessions.START_DATE)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Sessions.TYPE)),
                      track,
                      cursor.getString(cursor.getColumnIndex(DbContract.Sessions.LEVEL)),
                      microlocation
              );
          } catch (ParseException e) {
              Timber.e("Parsing Error Occurred at DatabaseOperations::getSessionById.");
          }
          cursor.close();
  
          return session;
      }
  
      public org.fossasia.openevent.data.Microlocation getMicroLocationById(int id, SQLiteDatabase mDb) {
          String selection = DbContract.Microlocation.ID + EQUAL + id;
          Cursor cursor = mDb.query(
                  DbContract.Microlocation.TABLE_NAME,
                  DbContract.Microlocation.FULL_PROJECTION,
                  selection,
                  null,
                  null,
                  null,
                  null
          );
  
          org.fossasia.openevent.data.Microlocation location = null;
          cursor.moveToFirst();
          while (!cursor.isAfterLast()) {
  
              //Should return only one due to UNIQUE constraint
              location = new org.fossasia.openevent.data.Microlocation(
                      cursor.getInt(cursor.getColumnIndex(DbContract.Microlocation.ID)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Microlocation.NAME)),
                      cursor.getFloat(cursor.getColumnIndex(DbContract.Microlocation.LATITUDE)),
                      cursor.getFloat(cursor.getColumnIndex(DbContract.Microlocation.LONGITUDE)),
                      cursor.getInt(cursor.getColumnIndex(DbContract.Microlocation.FLOOR))
              );
              cursor.moveToNext();
          }
          cursor.close();
  
          return location;
      }
  
      public List<Speaker> getSpeakerList(SQLiteDatabase mDb, String sortBy) {
  
          String sortOrder = sortBy + ASCENDING;
          Cursor cur = mDb.query(
                  DbContract.Speakers.TABLE_NAME,
                  DbContract.Speakers.FULL_PROJECTION,
                  null,
                  null,
                  null,
                  null,
                  sortOrder
          );
  
  
          List<Speaker> speakers = new ArrayList<>();
          Speaker s;
  
          cur.moveToFirst();
          while (!cur.isAfterLast()) {
              s = new Speaker(
                      cur.getInt(cur.getColumnIndex(DbContract.Speakers.ID)),
                      cur.getString(cur.getColumnIndex(DbContract.Speakers.NAME)),
                      cur.getString(cur.getColumnIndex(DbContract.Speakers.PHOTO)),
                      cur.getString(cur.getColumnIndex(DbContract.Speakers.BIO)),
                      cur.getString(cur.getColumnIndex(DbContract.Speakers.EMAIL)),
                      cur.getString(cur.getColumnIndex(DbContract.Speakers.WEB)),
                      cur.getString(cur.getColumnIndex(DbContract.Speakers.TWITTER)),
                      cur.getString(cur.getColumnIndex(DbContract.Speakers.FACEBOOK)),
                      cur.getString(cur.getColumnIndex(DbContract.Speakers.GITHUB)),
                      cur.getString(cur.getColumnIndex(DbContract.Speakers.LINKEDIN)),
                      cur.getString(cur.getColumnIndex(DbContract.Speakers.ORGANISATION)),
                      cur.getString(cur.getColumnIndex(DbContract.Speakers.POSITION)),
                      null,
                      cur.getString(cur.getColumnIndex(DbContract.Speakers.COUNTRY))
  
              );
              speakers.add(s);
              cur.moveToNext();
          }
          cur.close();
          return speakers;
      }
  
      public Version getVersionIds(SQLiteDatabase mDb) {
  
          Cursor cursor = mDb.query(
                  DbContract.Versions.TABLE_NAME,
                  DbContract.Versions.FULL_PROJECTION,
                  null,
                  null,
                  null,
                  null,
                  null
          );
  
          Version currentVersion;
          if (cursor != null && cursor.getCount() > 0) {
              cursor.moveToFirst();
  
              currentVersion = new Version(
                      cursor.getInt(cursor.getColumnIndex(DbContract.Versions.VER_EVENT)),
                      cursor.getInt(cursor.getColumnIndex(DbContract.Versions.VER_TRACKS)),
                      cursor.getInt(cursor.getColumnIndex(DbContract.Versions.VER_SESSIONS)),
                      cursor.getInt(cursor.getColumnIndex(DbContract.Versions.VER_SPONSORS)),
                      cursor.getInt(cursor.getColumnIndex(DbContract.Versions.VER_SPEAKERS)),
                      cursor.getInt(cursor.getColumnIndex(DbContract.Versions.VER_MICROLOCATIONS))
              );
              cursor.close();
              return currentVersion;
  
          } else {
              return null;
          }
      }
  
      public List<org.fossasia.openevent.data.Track> getTrackList(SQLiteDatabase mDb) {
          String sortOrder = DbContract.Tracks.ID + ASCENDING;
          Cursor cursor = mDb.query(
                  DbContract.Tracks.TABLE_NAME,
                  DbContract.Tracks.FULL_PROJECTION,
                  null,
                  null,
                  null,
                  null,
                  sortOrder
          );
          List<org.fossasia.openevent.data.Track> tracks = new ArrayList<>();
          org.fossasia.openevent.data.Track track;
  
          cursor.moveToFirst();
          while (!cursor.isAfterLast()) {
              track = new org.fossasia.openevent.data.Track(
                      cursor.getInt(cursor.getColumnIndex(DbContract.Tracks.ID)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Tracks.NAME)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Tracks.DESCRIPTION)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Tracks.IMAGE))
              );
              tracks.add(track);
              cursor.moveToNext();
          }
          cursor.close();
          return tracks;
      }
  
  
      public ArrayList<Sponsor> getSponsorList(SQLiteDatabase mDb) {
          String sortOrder = DbContract.Sponsors.LEVEL + ASCENDING + ", " + DbContract.Sponsors.NAME + ASCENDING;
          Cursor cursor = mDb.query(
                  DbContract.Sponsors.TABLE_NAME,
                  DbContract.Sponsors.FULL_PROJECTION,
                  null,
                  null,
                  null,
                  null,
                  sortOrder
          );
  
          ArrayList<Sponsor> sponsors = new ArrayList<>();
          Sponsor sponsor;
  
          cursor.moveToFirst();
  
          while (!cursor.isAfterLast()) {
              sponsor = new Sponsor(
                      cursor.getInt(cursor.getColumnIndex(DbContract.Sponsors.ID)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Sponsors.NAME)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Sponsors.URL)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Sponsors.LOGO_URL)),
                      cursor.getString(cursor.getColumnIndex(DbContract.Sponsors.TYPE)),
                      cursor.getInt(cursor.getColumnIndex(DbContract.Sponsors.LEVEL))
  
              );
              sponsor.changeSponsorTypeToString(cursor.getString(cursor.getColumnIndex(DbContract.Sponsors.TYPE)));
  
              sponsors.add(sponsor);
              cursor.moveToNext();
          }
          cursor.close();
          return sponsors;
      }
  
  
      public ArrayList<org.fossasia.openevent.data.Microlocation> getMicrolocationsList(SQLiteDatabase mDb) {
          String sortOrder = DbContract.Microlocation.NAME + ASCENDING;
          Cursor cursor = mDb.query(
                  DbContract.Microlocation.TABLE_NAME,
                  DbContract.Microlocation.FULL_PROJECTION,
                  null,
                  null,
                  null,
                  null,
                  sortOrder
          );
  
          ArrayList<org.fossasia.openevent.data.Microlocation> microlocations = new ArrayList<>();
          org.fossasia.openevent.data.Microlocation microlocation;
  
          cursor.moveToFirst();
  