Search code examples
javaandroidarraylistsparse-array

Making SparseArray<> Included ArrayList<String>


i need to make a List of ArrayList , my idea was it:

 Map<Integer, ArrayList<String>> SentReportMap=new HashMap<Integer, ArrayList<String>>();

that tell :

 Use new SparseArray<ArrayList<String>>(...) instead for better performance

so , i try this :

 SparseArray<String> SentReportMap = new SparseArray<String>();

 ArrayList<String> items=new ArrayList<String>();

 items.add(array.getProperty("To").toString());
 items.add(array.getProperty("Date").toString());

 SentReportMap.put(1, items);

but for fill this array with data , return this error :

The method put(int, String) in the type SparseArray<String> is not applicable for the arguments (int, ArrayList<String>)

Or

The method put(int, String) in the type SparseArray<String> is not applicable for the arguments (ArrayList<String>, int)

where is wrong and what is better solution for making a arraylist of arrays!?


Solution

  • Declaration of SentReportMap is wrong, it should be:

    SparseArray<ArrayList<String>> SentReportMap = new SparseArray<ArrayList<String>>();