title: Delete items from listView Firebase
body: <p>I have this problem when i open the view of &quot;Eventos&quot;, im trying to delete from de database the selected items from the listview.</p>
  <p><img src="https://i.stack.imgur.com/b43aZ.png" alt="enter image description here" /></p>
  <p>public class ShowData extends AppCompatActivity {</p>
  <pre><code>DatabaseReference databaseReference;
  ListView listView;
  ArrayList&lt;String&gt; arrayList = new ArrayList&lt;&gt;();
  ArrayAdapter&lt;String&gt; arrayAdapter;
  Button btnDelete;
  Module module;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_show_data);
      databaseReference = FirebaseDatabase.getInstance().getReference(&quot;Eventos&quot;);
      listView = (ListView) findViewById(R.id.listViewShow);
      btnDelete = (Button) findViewById(R.id.btnBorrarElemento);
      module=((Module)getApplication());
      arrayAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, arrayList);
      listView.setAdapter(arrayAdapter); .....
  
  
  ... listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; paramAdapterView, View view, int position, long id) {
              module.setGvalue_titulo(arrayList.get(position));
              module.setGvalue_descripcion(arrayList.get(position));
              module.setGvalue_fecha(arrayList.get(position));
              module.setGvalue_url(arrayList.get(position));
          }
      });
  
  
      btnDelete.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View v){
              final String str = module.getGvalue_titulo().substring(0, 6);
              if(str == &quot;&quot;){
                  Toast.makeText(ShowData.this, &quot;No se ha seleccionado ningun elemento para eliminar&quot;, Toast.LENGTH_SHORT).show();
              }
              else {
                  databaseReference.child(&quot;Eventos&quot;).child(str).addListenerForSingleValueEvent(new ValueEventListener() {
                      @Override
                      public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                          databaseReference.child(str).removeValue();
                      }
  
                      @Override
                      public void onCancelled(@NonNull DatabaseError databaseError) {
  
                      }
                  });
                  Toast.makeText(ShowData.this, &quot;Evento Eliminado&quot;, Toast.LENGTH_SHORT).show();
                  Intent intent = new Intent(getApplicationContext(),ShowData.class);
                  startActivity(intent);
              }
          }
      }); ....
  </code></pre>
  <p>The module has the getters and setters necessaries:
  <img src="https://i.stack.imgur.com/tA6qt.png" alt="enter image description here" /></p>
  <p>In my manifest, I have this:</p>
  <p><img src="https://i.stack.imgur.com/VuLy2.png" alt="enter image description here" /></p>