1

I have a bidimensional String array that has mass data (sizes are [40][8] to be exact) in my Activity A. I want to pass the whole array to Activity B. I've tried this solution: Passing string array between android activities

but the problem is it is creating an array inside. I want to pass my original bidimensional array that contains [40][8] values. Can I do that?

EDIT:

my String array is a 2 dimensional array.

6
  • you have two string arrays or a bidimensional string array? Commented Sep 30, 2016 at 15:57
  • and, which is the problem on creating a new array in activityB? I don't get it Commented Sep 30, 2016 at 15:58
  • i have only 1 string array. it is a 2 dimensional array. Sorry, i forgot to mention that. Commented Sep 30, 2016 at 16:04
  • I can create a new array on activity B. the problem is that i dont know how to pass my 2 dimensional array from activity A to a newly created 2 dimensional array on activity B. (the 2 dimensional array on activity B has nothing in it (null) i want to fill it with my 2 dimensional array from activity A.) Commented Sep 30, 2016 at 16:06
  • is it still confusing? Im sorry ... Commented Sep 30, 2016 at 16:06

1 Answer 1

1

Since your array is bidimensional and bidimensional array are serializable, you can use a bundle:

Intent intent = new Intent(this, activityB.class);
Bundle bundle = new Bundle();
bundle.putSerializable("myArray", myBidimensionalArray);
intent.putExtras(bundle);

and in activityB you can simply call:

Intent passed = getIntent();
Bundle bundle = passed.getExtras();
String[][] myPassedArray = (String[][]) bindle.getSerializable("myArray");

and you are done

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.