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;
...
}