title: Android studio remove items from both listview and firebase
body: <p>I'm trying to remove items from both listview and firebase in android studio.
  When I remove items from the firebase console, it automatically removes items from listview.
  However I want to remove items from the listview first, and want this changes to be reflected on the database.</p>
  
  <pre><code>public class PreferActivity extends AppCompatActivity {
      //Firebase Var
      private DatabaseReference mDatabase;
  
  //Android Layout
  private Button btnAdd;
  private EditText etText;
  private ListView listView;
  
  //Array list
  private ArrayList&lt;String&gt; arrayList = new ArrayList&lt;&gt;();
  private ArrayAdapter&lt;String&gt; adapter;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_prefer);
      mDatabase= FirebaseDatabase.getInstance().getReference();
  
      adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1,arrayList);
  
      btnAdd = (Button) findViewById(R.id.btnAdd);
      etText = (EditText) findViewById(R.id.etDatabase);
      listView = (ListView) findViewById(R.id.database_list_view);
  
      listView.setAdapter(adapter);
  
      btnAdd.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              mDatabase.push().setValue(etText.getText().toString());
          }
      });
  
  
      mDatabase.addChildEventListener(new ChildEventListener() {
          @Override
          public void onChildAdded(DataSnapshot dataSnapshot, String s) {
              String string = dataSnapshot.getValue(String.class);
  
              arrayList.add(string);
  
              adapter.notifyDataSetChanged();
          }
  
          @Override
          public void onChildChanged(DataSnapshot dataSnapshot, String s) {
  
          }
  
          @Override
          public void onChildRemoved(DataSnapshot dataSnapshot) {
              String string = dataSnapshot.getValue(String.class);
  
              arrayList.remove(string);
  
              adapter.notifyDataSetChanged();
          }
  
          @Override
          public void onChildMoved(DataSnapshot dataSnapshot, String s) {
  
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
  
          }
      });
  
  
  
  }
  }
  </code></pre>
  
  <p>Any comments would help me.
  Thanks in advance</p>