code: synchronized ArrayList<CTMessageDAO> getMessages(String userId){
          final String tName = Table.INBOX_MESSAGES.getName();
          Cursor cursor;
          ArrayList<CTMessageDAO> messageDAOArrayList = new ArrayList<>();
          try{
              final SQLiteDatabase db = dbHelper.getWritableDatabase();
              cursor= db.rawQuery("SELECT * FROM "+tName+" WHERE " + USER_ID + " = ? ORDER BY " + KEY_CREATED_AT+ " DESC", new String[]{userId});
              if(cursor != null) {
                  while(cursor.moveToNext()){
                      CTMessageDAO ctMessageDAO = new CTMessageDAO();
                      ctMessageDAO.setId(cursor.getString(cursor.getColumnIndex(_ID)));
                      ctMessageDAO.setJsonData(new JSONObject(cursor.getString(cursor.getColumnIndex(KEY_DATA))));
                      ctMessageDAO.setWzrkParams(new JSONObject(cursor.getString(cursor.getColumnIndex(WZRKPARAMS))));
                      ctMessageDAO.setDate(cursor.getLong(cursor.getColumnIndex(KEY_CREATED_AT)));
                      ctMessageDAO.setExpires(cursor.getLong(cursor.getColumnIndex(EXPIRES)));
                      ctMessageDAO.setRead(cursor.getInt(cursor.getColumnIndex(IS_READ)));
                      ctMessageDAO.setUserId(cursor.getString(cursor.getColumnIndex(USER_ID)));
                      ctMessageDAO.setTags(cursor.getString(cursor.getColumnIndex(TAGS)));
                      ctMessageDAO.setCampaignId(cursor.getString(cursor.getColumnIndex(CAMPAIGN)));
                      messageDAOArrayList.add(ctMessageDAO);
                  }
                  cursor.close();
              }
              return messageDAOArrayList;
          }catch (final SQLiteException e){
              getConfigLogger().verbose("Error retrieving records from " + tName, e);
              return null;
          } catch (JSONException e) {
              getConfigLogger().verbose("Error retrieving records from " + tName, e.getMessage());
              return null;
          } finally {
              dbHelper.close();
          }
      }
docs: Retrieves list of inbox messages based on given userId
  @param userId String userid
  @return ArrayList of {@link CTMessageDAO}