Android - How to make a link to a Xml file data
<p>I'm making an application with several xml file (toscana.xml, lazio.xml,...) that contain data, they are located in res/raw folder. I've got a spinner:</p>

<pre><code>import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.Spinner;

public class MainActivity extends Activity
{
private GridView grid;

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    grid = (GridView) findViewById(R.id.grid);
    aggiornaProvince(Provincia.TUTTE_LE_PROVINCE);

    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, Provincia.getRegioni());
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    spinner.setOnItemSelectedListener(new OnItemSelectedListener()
    {
        @Override
        public void onItemSelected(AdapterView&lt;?&gt; adapter, View v, int pos, long id)
        {
            aggiornaProvince((String) adapter.getItemAtPosition(pos));
        }

        @Override
        public void onNothingSelected(AdapterView&lt;?&gt; arg0)
        {
            aggiornaProvince(Provincia.TUTTE_LE_PROVINCE);
        }
    });
}

protected void aggiornaProvince(String regione)
{
    grid.setAdapter(new SimpleAdapter(this, Provincia.getData(regione), R.layout.cell, new String[]
    { Provincia.CODICE, Provincia.NOME }, new int[]
    { R.id.codice, R.id.nome }));
}
}
</code></pre>

<p>And this is Provincia activity:</p>

<pre><code>import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;

public class Provincia
{
public static final String TUTTE_LE_PROVINCE = "Tutte le province";

public static final String NOME = "NOME";

public static final String CODICE = "CODICE";

public static final String REGIONE = "REGIONE";

private String nome;

private String codice;

private String regione;

public Provincia(String nome, String codice, String regione)
{
    super();
    this.nome = nome;
    this.codice = codice;
    this.regione = regione;
}

public String getNome()
{
    return nome;
}

public String getCodice()
{
    return codice;
}

public String getRegione()
{
    return regione;
}

@Override
public String toString()
{
    return nome + " " + codice;
}

public boolean isRegioneStatutoSpeciale()
{
    return regione.equals("Valle d'Aosta") || regione.equals("Trentino Alto Adige") || regione.equals("Friuli Venezia Giulia")
            || regione.equals("Sardegna") || regione.equals("Sicilia");
}

public static final Provincia[] DB = new Provincia[]
{ new Provincia("Agrigento", "AG", "Sicilia"), new Provincia("Alessandria", "AL", "Piemonte"), new Provincia("Ancona", "AN", "Marche"),
        new Provincia("Aosta", "AO", "Valle d'Aosta"), new Provincia("Arezzo", "AR", "Toscana"), new Provincia("Ascoli Piceno", "AP", "Marche"),
        new Provincia("Asti", "AT", "Piemonte"), new Provincia("Avellino", "AV", "Campania"), new Provincia("Bari", "BA", "Puglia"),
        new Provincia("Barletta Andria Trani", "BT", "Puglia"), new Provincia("Belluno", "BL", "Veneto"),
        new Provincia("Benevento", "BN", "Campania"), new Provincia("Bergamo", "BG", "Lombardia"), new Provincia("Biella", "BI", "Piemonte"),
        new Provincia("Bologna", "BO", "Emilia Romagna"), new Provincia("Bolzano", "BZ", "Trentino Alto Adige"),
        new Provincia("Brescia", "BS", "Lombardia"), new Provincia("Brindisi", "BR", "Puglia"), new Provincia("Cagliari", "CA", "Sardegna"),
        new Provincia("Caltanissetta", "CL", "Sicilia"), new Provincia("Campobasso", "CB", "Molise"),
        new Provincia("Carbonia Iglesias", "CI", "Sardegna"), new Provincia("Caserta", "CE", "Campania"),
        new Provincia("Catania", "CT", "Sicilia"), new Provincia("Catanzaro", "CZ", "Calabria"), new Provincia("Chieti", "CH", "Abruzzo"),
        new Provincia("Como", "CO", "Lombardia"), new Provincia("Cosenza", "CS", "Calabria"), new Provincia("Cremona", "CR", "Lombardia"),
        new Provincia("Crotone", "KR", "Calabria"), new Provincia("Cuneo", "CN", "Piemonte"), new Provincia("Enna", "EN", "Sicilia"),
        new Provincia("Fermo", "FM", "Marche"), new Provincia("Ferrara", "FE", "Emilia Romagna"), new Provincia("Firenze", "FI", "Toscana"),
        new Provincia("Foggia", "FG", "Puglia"), new Provincia("Forlì Cesena", "FC", "Emilia Romagna"),
        new Provincia("Frosinone", "FR", "Lazio"), new Provincia("Genova", "GE", "Liguria"),
        new Provincia("Gorizia", "GO", "Friuli Venezia Giulia"), new Provincia("Grosseto", "GR", "Toscana"),
        new Provincia("Imperia", "IM", "Liguria"), new Provincia("Isernia", "IS", "Molise"), new Provincia("La Spezia", "SP", "Liguria"),
        new Provincia("L'Aquila", "AQ", "Abruzzo"), new Provincia("Latina", "LT", "Lazio"), new Provincia("Lecce", "LE", "Puglia"),
        new Provincia("Lecco", "LC", "Lombardia"), new Provincia("Livorno", "LI", "Toscana"), new Provincia("Lodi", "LO", "Lombardia"),
        new Provincia("Lucca", "LU", "Toscana"), new Provincia("Macerata", "MC", "Marche"), new Provincia("Mantova", "MN", "Lombardia"),
        new Provincia("Massa e Carrara", "MS", "Toscana"), new Provincia("Matera", "MT", "Basilicata"),
        new Provincia("Medio Campidano", "VS", "Sardegna"), new Provincia("Messina", "ME", "Sicilia"),
        new Provincia("Milano", "MI", "Lombardia"), new Provincia("Modena", "MO", "Emilia Romagna"),
        new Provincia("Monza e Brianza", "MB", "Lombardia"), new Provincia("Napoli", "NA", "Campania"),
        new Provincia("Novara", "NO", "Piemonte"), new Provincia("Nuoro", "NU", "Sardegna"), new Provincia("Ogliastra", "OG", "Sardegna"),
        new Provincia("Olbia Tempio", "OT", "Sardegna"), new Provincia("Oristano", "OR", "Sardegna"), new Provincia("Padova", "PD", "Veneto"),
        new Provincia("Palermo", "PA", "Sicilia"), new Provincia("Parma", "PR", "Emilia Romagna"), new Provincia("Pavia", "PV", "Lombardia"),
        new Provincia("Perugia", "PG", "Umbria"), new Provincia("Pesaro e Urbino", "PU", "Marche"), new Provincia("Pescara", "PE", "Abruzzo"),
        new Provincia("Piacenza", "PC", "Emilia Romagna"), new Provincia("Pisa", "PI", "Toscana"), new Provincia("Pistoia", "PT", "Toscana"),
        new Provincia("Pordenone", "PN", "Friuli Venezia Giulia"), new Provincia("Potenza", "PZ", "Basilicata"),
        new Provincia("Prato", "PO", "Toscana"), new Provincia("Ragusa", "RG", "Sicilia"), new Provincia("Ravenna", "RA", "Emilia Romagna"),
        new Provincia("Reggio Calabria", "RC", "Calabria"), new Provincia("Reggio Emilia", "RE", "Emilia Romagna"),
        new Provincia("Rieti", "RI", "Lazio"), new Provincia("Rimini", "RN", "Emilia Romagna"), new Provincia("Roma", "RM", "Lazio"),
        new Provincia("Rovigo", "RO", "Veneto"), new Provincia("Salerno", "SA", "Campania"), new Provincia("Sassari", "SS", "Sardegna"),
        new Provincia("Savona", "SV", "Liguria"), new Provincia("Siena", "SI", "Toscana"), new Provincia("Siracusa", "SR", "Sicilia"),
        new Provincia("Sondrio", "SO", "Lombardia"), new Provincia("Taranto", "TA", "Puglia"), new Provincia("Teramo", "TE", "Abruzzo"),
        new Provincia("Terni", "TR", "Umbria"), new Provincia("Torino", "TO", "Piemonte"), new Provincia("Trapani", "TP", "Sicilia"),
        new Provincia("Trento", "TN", "Trentino Alto Adige"), new Provincia("Treviso", "TV", "Veneto"),
        new Provincia("Trieste", "TS", "Friuli Venezia Giulia"), new Provincia("Udine", "UD", "Friuli Venezia Giulia"),
        new Provincia("Varese", "VA", "Lombardia"), new Provincia("Venezia", "VE", "Veneto"),
        new Provincia("Verbano Cusio Ossola", "VB", "Piemonte"), new Provincia("Vercelli", "VC", "Piemonte"),
        new Provincia("Verona", "VR", "Veneto"), new Provincia("Vibo Valentia", "VV", "Calabria"), new Provincia("Vicenza", "VI", "Veneto"),
        new Provincia("Viterbo", "VT", "Lazio") };

private static ArrayList&lt;String&gt; regioni;

public static List&lt;Map&lt;String, String&gt;&gt; getData()
{
    List&lt;Map&lt;String, String&gt;&gt; ret = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
    for (Provincia provincia : DB)
    {
        ret.add(provincia.getMap());
    }
    return ret;
}

public static List&lt;Map&lt;String, String&gt;&gt; getData(String regione)
{
    List&lt;Map&lt;String, String&gt;&gt; ret = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
    for (Provincia provincia : DB)
    {
        if (regione.equals(TUTTE_LE_PROVINCE) || regione.equals(provincia.getRegione()))
        {
            ret.add(provincia.getMap());
        }
    }
    return ret;
}

private Map&lt;String, String&gt; getMap()
{
    HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
    map.put(NOME, nome);
    map.put(CODICE, codice);
    map.put(REGIONE, regione);
    return map;
}

public static ArrayList&lt;String&gt; getRegioni()
{
    if (regioni == null)
    {
        TreeSet&lt;String&gt; set = new TreeSet&lt;String&gt;();
        for (Provincia provincia : DB)
        {
            set.add(provincia.getRegione());
        }
        regioni = new ArrayList&lt;String&gt;();
        regioni.add(TUTTE_LE_PROVINCE);
        regioni.addAll(set);
    }
    return regioni;
}
}
</code></pre>

<p>When I click "Toscana" on spinner it gives me some results, and if I clik on "Firenze" I would like to open a new layout where I can see all the informations about "Firenze". All the informations are in xml files in res/raw folder. How can I make to open that xml file from results of my spinner? I hope someone understood what I wrote. Thank you very much.</p>
