title: Can we delete a node in one child and update another in another child with one button click in android
body: <p>I want to create history for my app. What I want is, when the customer clicks the reject button so the data from the request activity should be deleted, and added to rejected requests activity. Please help me someone. 
  This is my adapter class, where I am deleting the requests for both driver and parking owner, but now I want to add it the rejected requests activity. </p>
  
  <p>public class CustomAdapter extends ArrayAdapter {</p>
  
  <pre><code>private DatabaseReference databaseReference;
  private Activity context;
  private List&lt;parkingRequest&gt; parkingRequestList;
  private String send_email_driver;
  private FirebaseAuth mAuth;
  private DatabaseReference mAcceptedRequests, mRejectedRequests;
  private String userId;
  
  
  public CustomAdapter(Activity context, List&lt;parkingRequest&gt; parkingRequestList) {
      super(context, R.layout.sample_layout, parkingRequestList);
      this.context = context;
      this.parkingRequestList = parkingRequestList;
  
  
      mAuth = FirebaseAuth.getInstance();
      userId = mAuth.getCurrentUser().getUid();
      mAcceptedRequests = FirebaseDatabase.getInstance().getReference().child("History").child("AcceptedRequests").child(userId);
      mRejectedRequests = FirebaseDatabase.getInstance().getReference().child("History").child("RejectedRequests").child(userId);
  
  
      OneSignal.startInit(getContext())
              .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
              .unsubscribeWhenNotificationsAreDisabled(true)
              .init();
  
  }
  
  @NonNull
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
  
      LayoutInflater layoutInflater = context.getLayoutInflater();
      View view = layoutInflater.inflate(R.layout.sample_layout, null, true);
      final parkingRequest Request1 = parkingRequestList.get(position);
      TextView t1 = view.findViewById(R.id.nameTxt);
      TextView t2 = view.findViewById(R.id.phoneTxt);
      TextView t3 = view.findViewById(R.id.carNoTxt);
      TextView txtParkingLocation=view.findViewById(R.id.txtparkingLocation);
      TextView pDate_time = view.findViewById(R.id.pdateTime);
  
  
      final TextView driverEmail = view.findViewById(R.id.driverEmail);
      final TextView DriverId = view.findViewById(R.id.driverid);
  
      final Button reject = view.findViewById(R.id.RejectBtn);
      final Button accept = view.findViewById(R.id.acceptBtn);
  
  
  
      pDate_time.setText(Request1.getDate_time());
  
  
      reject.setOnClickListener(new View.OnClickListener() {
          @Override
      public void onClick(View v) {
              String id=FirebaseAuth.getInstance().getCurrentUser().getUid();
  
              Toast.makeText(context,id,Toast.LENGTH_SHORT).show();
              DatabaseReference ref=FirebaseDatabase.getInstance().getReference().child("CurrentRequests").child(id).child(reject.getTag().toString());
              ref.removeValue();
  
              DatabaseReference refOwner=FirebaseDatabase.getInstance().getReference().child("CurrentRequests").child(DriverId.getTag().toString()).child(reject.getTag().toString());
              refOwner.removeValue();
          }
  
      });
  
      accept.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              //Toast.makeText(context, "Hello", Toast.LENGTH_SHORT).show();
              send_email_driver = driverEmail.getTag().toString();
              sendPushNotification();
  
          }
      });
  
  
      t1.setText("Name: "+ Request1.getName());
      t2.setText("Phone:  "+ Request1.getPhone());
      t3.setText("CarNo: "+ Request1.getCarNO());
      txtParkingLocation.setText("Location:   "+Request1.getParking_location());
      reject.setTag(Request1.getReq_id());
      DriverId.setTag(Request1.getUser_ID());
      DriverId.setVisibility(View.INVISIBLE);
      driverEmail.setTag(Request1.getDriver_email());
      driverEmail.setVisibility(View.INVISIBLE);
  
      return view;
  }
  
  
  
  private void sendPushNotification() {
  
  
      AsyncTask.execute(new Runnable() {
          @Override
          public void run() {
              int SDK_INT = Build.VERSION.SDK_INT;
              if(SDK_INT &gt; 0){
                  StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                          .permitAll().build();
                  StrictMode.setThreadPolicy(policy);
  
                  try {
  
                      String jsonResponse;
  
                      URL url = new URL("https://onesignal.com/api/v1/notifications");
                      HttpURLConnection con = (HttpURLConnection) url.openConnection();
                      con.setUseCaches(false);
                      con.setDoOutput(true);
                      con.setDoInput(true);
                      con.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
                      con.setRequestProperty("Authorization", "Basic OWFiYjg5ZDAtNzY0My00MDdkLThjMTAtZjEyMjJiZTU3MzI2");
                      con.setRequestMethod("POST");
  
                      String strJsonBody = "{"
                              + "\"app_id\": \"f0b4bf7b-f76e-4d6b-91b9-dc09af30754c\","
  
                              + "\"filters\": [{\"field\": \"tag\", \"key\": \"User_ID\", \"relation\": \"=\", \"value\": \"" + send_email_driver + "\"}],"
  
                              + "\"data\": {\"foo\": \"bar\"},"
                              + "\"headings\": {\"en\": \"Parking Reply\"},"
  
                              + "\"contents\": {\"en\": \"Your request for a parking slot in the following parking is accepted.\"},"
  
  
                              + "\"buttons\": [{\"id\":\"SeeMapBtn\",\"text\":\"See the Map\",\"icon\":\"\"}]"
  
                              + "}";
  
                      System.out.println("strJsonBody:\n" + strJsonBody);
  
                      byte[] sendBytes = strJsonBody.getBytes("UTF-8");
                      con.setFixedLengthStreamingMode(sendBytes.length);
  
                      OutputStream outputStream = con.getOutputStream();
                      outputStream.write(sendBytes);
  
                      int httpResponse = con.getResponseCode();
                      System.out.println("httpResponse: " + httpResponse);
  
                      if (httpResponse &gt;= HttpURLConnection.HTTP_OK
                              &amp;&amp; httpResponse &lt; HttpURLConnection.HTTP_BAD_REQUEST) {
                          Scanner scanner = new Scanner(con.getInputStream(), "UTF-8");
                          jsonResponse = scanner.useDelimiter("\\A").hasNext() ? scanner.next() : "";
                          scanner.close();
                      } else {
                          Scanner scanner = new Scanner(con.getErrorStream(), "UTF-8");
                          jsonResponse = scanner.useDelimiter("\\A").hasNext() ? scanner.next() : "";
                          scanner.close();
                      }
                      System.out.println("jsonResponse:\n" + jsonResponse);
  
  
                  } catch (MalformedURLException e) {
                      e.printStackTrace();
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
  
              }
          }
      });
  
  }
  </code></pre>
  
  <p>}</p>