code: synchronized int storeObject(JSONObject obj, Table table) {
          if (!this.belowMemThreshold()) {
              Logger.v("There is not enough space left on the device to store data, data discarded");
              return DB_OUT_OF_MEMORY_ERROR;
          }
  
          final String tableName = table.getName();
  
          Cursor cursor = null;
          int count = DB_UPDATE_ERROR;
  
          //noinspection TryFinallyCanBeTryWithResources
          try {
              final SQLiteDatabase db = dbHelper.getWritableDatabase();
  
              final ContentValues cv = new ContentValues();
              cv.put(KEY_DATA, obj.toString());
              cv.put(KEY_CREATED_AT, System.currentTimeMillis());
              db.insert(tableName, null, cv);
              cursor = db.rawQuery("SELECT COUNT(*) FROM " + tableName, null);
              cursor.moveToFirst();
              count = cursor.getInt(0);
          } catch (final SQLiteException e) {
              getConfigLogger().verbose("Error adding data to table " + tableName + " Recreating DB");
  
              if (cursor != null) {
                  cursor.close();
                  cursor = null;
              }
              dbHelper.deleteDatabase();
          } finally {
              if (cursor != null) {
                  cursor.close();
              }
              dbHelper.close();
          }
          return count;
      }
docs: Adds a JSON string to the DB.
  
  @param obj   the JSON to record
  @param table the table to insert into
  @return the number of rows in the table, or DB_OUT_OF_MEMORY_ERROR/DB_UPDATE_ERROR