-1
ArrayList<ArrayList<String>> HoldAllData = new ArrayList<ArrayList<String>>();              

can i send HoldAllData to another activity using putStringArrayListExtra? i know how to send ArrayList<String> to another activity but this is a list of string list. HoldAllData is filled by database read values and is a n-row by 5-columns list of strings.

Hossein Amini
  • 716
  • 9
  • 21
  • Should be `List> HoldAllData = new ArrayList>();` – EpicPandaForce Jul 07 '14 at 09:46
  • no it shouldn't because it is working and holds all database values – Hossein Amini Jul 07 '14 at 09:46
  • Of course it works, but that doesn't make it the right practice. See http://stackoverflow.com/questions/9852831/polymorphism-why-use-list-list-new-arraylist-instead-of-arraylist-list-n and http://stackoverflow.com/questions/147468/why-should-the-interface-for-a-java-class-be-prefered – EpicPandaForce Jul 07 '14 at 09:47
  • u r wrong, ur code give me error. the correct implementation is: List> HoldAllDatar = new ArrayList>(); – Hossein Amini Jul 07 '14 at 09:52
  • You ARE right and wrong at the same time, it should be `List> HoldAllData = new ArrayList>();` sorry about the initial error. – EpicPandaForce Jul 07 '14 at 09:53

1 Answers1

1

Well you can achieve the same by setting data in the bundle through .putSerializable("key", HoldAllData ); then later to retrieve the list in other activity cast the serializable data Object o = bundle.getSerializable("key"); if o instanceof ArrayList<ArrayList<String>> ArrayList<ArrayList<String>> holdAllData = (ArrayList<ArrayList<String>>)o;

Pr38y
  • 1,565
  • 13
  • 21