0

I put an Object "myLiztz" into a FirebaseDatabase.

After removing an Item from an ArrayList, which is a Member of the Object, the setValue-Method causes an InvocationTargetException.

What's going wrong?

 public class LiztzFragment extends Fragment implements View.onClickListener {
 

 private Liztz myLiztz;

 
 @Override
 public View onCreateView(
         LayoutInflater inflater, ViewGroup container,
         Bundle savedInstanceState
 ) {...}

 public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
     
     super.onViewCreated(view, savedInstanceState);

     myLiztz = new Liztz();

     mDatabase.addValueEventListener(new ValueEventListener() {
         @Override
         public void onDataChange(@NonNull DataSnapshot snapshot) {...}

         @Override
         public void onCancelled(@NonNull DatabaseError error) {

         }
     });

     btnAddList.setOnClickListener(this);
 }

 @Override
 public void onClick(View v) {
     
             mDatabase.setValue(myLiztz); //here's no Problem
             if (myLiztz.liztz.get((int) v.getTag()).isDeletable) {
                 myLiztz.liztz.remove((int) v.getTag()); 

                 mDatabase.setValue(myLiztz);//at this Point the Exception ist thrown

             }
             break;
     }
 } }

Here is the Liztz-Object.

 public class Liztz implements Serializable {
     public ArrayList<Lizt> liztz;
     public int activeLiztIndex;
     ...
 } 
Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
Zzzzaphod
  • 1
  • 1

1 Answers1

0

I now solved the problem by creating a new Object:

mDatabase.setValue(new Liztz(myLiztz));

Nevertheless I don't understand the error.

Zzzzaphod
  • 1
  • 1