title: How to get max value from SQLite table column and return it to variable in MainActivity. Android Studio
body: <ol>
  <li><p>Created the table in <strong>DBHelper.java</strong>:</p>
  
  <pre><code>@Override
  public void onCreate(SQLiteDatabase db) {
  db.execSQL("create table " + TABLE_WORKOUT + "("
          + KEY_ID + " INTEGER PRIMARY KEY,"
          + KEY_WONUMBER + " integer,"
          + KEY_WONAME + " text,"
          + KEY_WODESCRIPTION + " text,"
          + KEY_WOICON + " text,"
          + KEY_WOCOLOR + " text" + ")");}
  </code></pre></li>
  <li><p>In MainActivity.java  <strong>onCreate</strong> will be created some <strong>OBJECTS</strong>, that will be shown according to numbers from column KEY_WONUMBER of TABLE_WORKOUT</p></li>
  <li><p>Need to find max value in KEY_WONUMBER and give it to variable in MainActivity.java and set next number for the next <strong>OBJECT</strong></p></li>
  <li><p>Trying to do it like this:</p>
  
  <pre><code>    public String getMaxNumber(){
      SQLiteDatabase db = dbHelper.getWritableDatabase();
      Cursor c = db.query(DBHelper.TABLE_WORKOUT, new String[]
              {"MAX("+DBHelper.KEY_WONUMBER+")"},
              null, null, null, null, null);
  
      StringBuffer buffer;
      if(c.getCount()&gt;0){
          c.moveToFirst();
          String max_id=c.getString(0);
          buffer.append(max_id);
      }
  
      c.close();
      db.close();
      return buffer.toString();
  }
  </code></pre></li>
  <li><p>Getting next mistakes in raws:</p>
  
  <p>public String getMaxNumber(){    -   <em>';' expected</em></p>
  
  <p>return buffer.toString();        -   *cannot return a value from a method with void result type</p></li>
  </ol>
  
  <p>As a newbie in Android need your help to solve that problem</p>