Main purpose of SparseArray in Android development is to have a memory efficient integer to object mapping.
It is not solely about to gain a performance tweak, however, you will save much more memory by using SparseArray.
Benefits of SparseArray
- Saves you memory (Less memory usage thanks to the primitive keys and no Entry objects)
- No auto-boxing (Because the keys are primitives e.g. int vs Integer, it will not convert your key to a new Integer(key))
- Less time spend in GC-Garbage Collection- (With auto boxing there will be redundant Integer and Entry objects in the memory which needs to be collected by GC after their usage end)