title: Cursor only returning one value / last value
body: <p>I am really stuck as I have a cursor that retrieves values from the database but the cursor only returns the last value. I need the cursor to retrieve all values so I can display them all later on. Is there any way as I can return all the data stored through the cursor? </p>
  
  <p>An Example as to whats happening. Eg Click on Button 1 and stores 1 perfectly but once I click on Button 2 and add 1. Button 1 data is not return or retrieved.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Execute </p>
  
  <p>The first Cursor is goes through to check all the stored items.</p>
  
  <pre><code>public void exectute() {
      AsyncTask.execute(new Runnable() {
          @Override
          public void run() {
              Cursor c = TrackerDb.getStoredItems(getApplicationContext());
              if (c != null) {
                  if (c.moveToFirst()) {
                      WorkoutDetails details = null;
                      //if (details != null) mWorkoutDetailsList.add(details);
                      do {
                          //if (details != null) mWorkoutDetailsList.add(details);
                          WorkoutDetails temp = getWorkoutFromCursor(c);
                          //if (details != null) mWorkoutDetailsList.add(details);
                          if (details == null) {
                              details = temp;
                              continue;
                          }
                          //if (details != null) mWorkoutDetailsList.add(details);
                          if (isSameDay(details.getWorkoutDate(), temp.getWorkoutDate())) {
                              //if (details != null) mWorkoutDetailsList.add(details);
                              if (DBG) Log.d(LOG_TAG, "isSameDay().. true");
                              //details.add(temp);
                          } else {
                              mWorkoutDetailsList.add(details);
                              details = temp;
                          }
                         // if (details != null) mWorkoutDetailsList.add(details);
                      } while (c.moveToNext());
                      if (details != null) mWorkoutDetailsList.add(details);
  
                      if (DBG)
                          Log.d(LOG_TAG, "AsyncTask: list size " + mWorkoutDetailsList.size());
  
                      runOnUiThread(new Runnable() {
                          @Override
                          public void run() {
                              mWorkoutsAdapter.updateList(mWorkoutDetailsList);
                          }
                      });
                  }
  
  
                  c.close();
              }
          }
      });
  }
  </code></pre>
  
  <p>Get Stored Items Code</p>
  
  <p>This is the code which the excute class calls and where the cursor only returns one value.</p>
  
  <pre><code>public static Cursor getStoredItems(Context context) {
      DBHelper dbHelper = new DBHelper(context);
      SQLiteDatabase db  = dbHelper.getWritableDatabase();
      String[] projection = {ID, TIME, TYPE, DURATION, DATE, POINT};
      String orderBy = TIME + " DESC";
      Cursor cursor = db.query(TABLE_NAME, projection, null, null, null, null, orderBy);
      return cursor;
  }
  </code></pre>
  
  <p>Array</p>
  
  <p>This is the array code where i want the cursor to store its values based on type.</p>
  
  <pre><code>private WorkoutDetails getWorkoutFromCursor(Cursor c) {
      long time = c.getLong(c.getColumnIndex(TrackerDb.TIME));
      int type = c.getInt(c.getColumnIndex(TrackerDb.TYPE));
      int duration = c.getInt(c.getColumnIndex(TrackerDb.DURATION));
      int point = c.getInt(c.getColumnIndex(TrackerDb.POINT));
  
      int totalMoney = MoneyActivity.Money.values().length;
      int[] points = new int[totalMoney];
  
      int totalActivities = MeditationTrackerActivity.ACTIVITIES.values().length;
      int[] durations = new int[totalActivities];
      if (type &lt; totalActivities) {
          durations[type] = duration;
      }
  
      if( type == 0) {
          for (int i = 0; i &lt; totalMoney; i++) {
              points[type] = point;
          }
      }
      else if ( type == 1) {
          for ( int ii = 0; ii &lt; totalMoney; ii++) {
              points[type] = point;
          }
      }
      else if ( type == 2) {
          for ( int iii = 0; iii &lt; totalMoney; iii++) {
              points[type] = point;
          }
      }
  
      return new WorkoutDetails(time, durations, points);
  }
  </code></pre>
  
  <p>Get Workout From Cursor Code</p>
  
  <pre><code>private static WorkoutDetails getWorkoutFromCursor(Cursor c) {
      long time = c.getLong(c.getColumnIndex(TrackerDb.TIME));
      int type = c.getInt(c.getColumnIndex(TrackerDb.TYPE));
      int duration = c.getInt(c.getColumnIndex(TrackerDb.DURATION));
      String date = c.getString(c.getColumnIndex(TrackerDb.DATE));
  
      int point = c.getInt(c.getColumnIndex(TrackerDb.POINT));
      int[] durations = new int[MeditationTrackerActivity.ACTIVITIES.values().length];
      durations[type] = duration;
  
      int[] points = new int[MoneyActivity.Money.values().length];
      points[type] = point;
      return new WorkoutDetails(time, durations, date, points);
  }
  </code></pre>