Jack
Jack

Reputation: 743

How to search XML file for specific elements without loading all elements?

I want to load the drawable names from appfilter.xml related to one of the installed icon packs, as you know that such file could contain 1000s of elements (sometimes more than 8000).

I found this code online which do the job but it loads all elements into the array, and for a better memory management and to avoid memory churn, I want to only search this file for the elements that I need (which could be a couple of 100s) and add them into my array.

So how could I accomplish this? What do you advise me

Code:

https://github.com/michelelacorte/FlickLauncher/blob/master/src/com/android/launcher3/util/IconPackManager.java

Upvotes: 0

Views: 55

Answers (1)

Gabe Sechan
Gabe Sechan

Reputation: 93678

Take their code. Create a HashSet of all the names you want. In the section where they add it to the array, add a check to see if the name is contained in your set. If it is, add it. If not, skip. Its a really simple alteration.

Upvotes: 1

Related Questions