Take the 2-minute tour ×

How can I pass a multidimensional array from one activity to another?

share|improve this question

1 Answer 1

You can create a Serializable class which wraps the two-dimensional array, and pass it using Intent.putExtra(String name, Serializable value)

share|improve this answer
I have to pass a 2-d string array. Can u please give some example of how to pass and retrieve the array using Intent.putExtra(String name, Serializable value) –  Maya Oct 26 '10 at 13:25
To build on what codelark said, you'd create a new class which implements the standard java.io.Serializable interface and then implement writeObject() and readObject() to send your Strings to & from the ObjectOutputStream. Once you have that class you can put instances of it into an Intent. –  Reuben Scratton Oct 26 '10 at 13:44
Of course, if you have thousands of strings this might be too slow. You could implement your own scheme to condense your array to a single String (e.g. joining the elements together with some character sequence that's guaranteed to not appear in the array content). –  Reuben Scratton Oct 26 '10 at 13:47
If you're passing thousands of strings, using any of the persistance strategies and passing the id to retrieve them would be a less-crazy thing to do. –  codelark Oct 26 '10 at 13:49

Your Answer


