@JavascriptInterface
    public void onSaveActivity(int status, String activityData) {
      Log.d(
          "Enter activity data",
          "save activity, status: " + status + ", activity: " + activityData);

      if (savedState != null) {
        savedState.putString("activity", activityData);
      } else {
        if (status < 0) {
          Toast.makeText(ctx, R.string.activity_not_modified, Toast.LENGTH_LONG).show();
        } else if (status > 0) {
          try {
            JSONObject activity = new JSONObject(activityData);

            ContentValues values = Mapper.mapActivity(activity);
            values.put(
                FieldCaptureContent.SYNC_STATUS, FieldCaptureContent.SYNC_STATUS_NEEDS_UPDATE);

            Uri uri = FieldCaptureContent.activityUri(activityId);

            ctx.getContentResolver()
                .update(
                    uri, values, FieldCaptureContent.ACTIVITY_ID + "=?", new String[] {activityId});

            if (newSite != null) {
              ctx.getContentResolver()
                  .insert(
                      FieldCaptureContent.siteUri(newSite.getAsString(FieldCaptureContent.SITE_ID)),
                      newSite);
            }

            FieldCaptureContent.requestSync(ctx, true);

            ctx.finish();
          } catch (Exception e) {
            Log.e("EnterActivityData", "Failed to save activity: " + activityData, e);
          }
        } else {
          Toast.makeText(ctx, R.string.activity_validation_failed, Toast.LENGTH_LONG).show();
        }
      }
    }
  @Override
  public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    switch (id) {
      case ACTIVITY_LOADER_ID:
        String activityId = args.getString(ARG_ACTIVITY_ID);
        Uri activityUri = FieldCaptureContent.activityUri(activityId);
        return new CursorLoader(
            getActivity(),
            activityUri,
            null,
            FieldCaptureContent.ACTIVITY_ID + "=?",
            new String[] {activityId},
            null);
      case SITES_LOADER_ID:
        Uri sitesUri = FieldCaptureContent.sitesUri();
        return new CursorLoader(getActivity(), sitesUri, null, null, null, null);
      default:
        return null;
    }
  }