Question: I'm currently using a Parser and it parses every time the onCreate gets called.
My parser uses an XML file that's located in my assetfolder.

Is there any chance that I can make it parse only once, instead of every time I rotate the screen or restart the application?

Thank you :)

Answer: 
Persist a flag using the Preferences system the first time you complete a parse, and check this each time before parsing again. Do all this in your OnCreate() method.

```
    SharedPreferences settings = getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
    if (!settings.getBoolean("parsed", false)) {
        parseTheXML();

        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean("parsed",  true);
        editor.commit();
    }

```

There are other ways but this has the advantage of working across app reloads/phone power cycles - assuming that's what you want.
You could add a preference. Something like -

```
void setIsAppOpened() {
    editor.putBoolean(APP_OPENED, true);
    editor.commit();
}

```

Set it in your onCreate(). Then, also add the following code to check if the preference exists.

```
if (!prefs.contains(APP_OPENED))
    {
        //parse the XML
        setIsAppOpened();
    }

```