title: Cannot access variable inside inner class without making it Final
body: <p>The code asks the user if they want to delete the entry from the recyclerview / mysql database. The functionality works, however if the user selects no the item is still getting deleted from the recycler-view (temporarily) until the screen is refreshed then it comes back. I tried moving the removeItem(position) method into the yes/no method. However it states the variable must be made final. If I make it final it breaks the functionality. How can I arrange this code in a way where when the user clicks no the viewholder isnt removed?</p>
  
  <pre><code> /**
   * Method which removes a row from the recycler-view view-holder. Also captured the cbtId Primary Key which is sent
    * via Retrofit to the server to ensure the correct row is deleted from the database.
   * @param position
   */
  public void removeItem(int position) {
      cbtId = mWorkoutLogList.get(position).getCbtId();
      mWorkoutLogList.remove(position);
      mWorkoutLogAdapter.notifyItemRemoved(position);
  }
  
  
  /**
   * On click method which calls the deleteLog() method to delete the row from the recycler view.
   * @param position
   */
  @Override
  public void onDeleteClick(int position) {
  
      deleteLog(position);
  
  }
  
  
  /**
   * Method which uses Retrofit to send a call to the MYSQL server to delete a workout log.
   */
  private void deleteLog(int position){
  
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      builder.setTitle("Are you Sure?");
      builder.setMessage("Deleted Workout Logs cannot be restored.");
      builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
  
              Call&lt;WorkoutLogList&gt; call = RetrofitClient.getInstance().getApi().deleteLog(cbtId);
              call.enqueue(new Callback&lt;WorkoutLogList&gt;() {
                  @Override
                  public void onResponse(Call&lt;WorkoutLogList&gt; call, Response&lt;WorkoutLogList&gt; response) {
                      removeItem(position);
                  }
  
                  @Override
                  public void onFailure(Call&lt;WorkoutLogList&gt; call, Throwable t) {
  
                  }
              });
          }
      });
      builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
  
          }
      });
  
      AlertDialog ad = builder.create();
      ad.show();
  
  }
  </code></pre>