I'm trying to send a 2D array through an Intent by using Bundle.putSerializable, but am getting a ClassCastException error when retrieving it.
The code I'm using is more or less exactly what other StackOverflow users have reported as working for them, so I'm not certain why I'm getting this error.
I have a 2D Array which I add to my Bundle and Intent as follows:
String[][] myString= new String[myGroup.length][myGroup[0].length];
//Data is added to String here
Bundle myBundle = new Bundle();
myBundle.putSerializable("myString", myString);
intent.putExtras(myBundle);
And retrieve in the next Activity as follows:
Bundle myBundle = getIntent().getExtras();
String[][] myNewString= (String[][]) myBundle.getSerializable("myString");
However, at Runtime I get the error:
java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.String[[][]
And I'm not certain why, as other users seemingly reported success with this. Would I be better served taking another approach?
Thanks in advance.