Q:

How to use List in android?

How should I use List<Data> dat = new List<Data>(); to temporary store data in my software? "Data" is a class in my code with variables(mainly Strings). When I try that method it doesn't store data.

A:

List is an interface, so you can't instantiate it (call new List()) as it does not have a concrete implementation. To keep it simple, use one of the existing implementations, for example:
List<Data> dat = new ArrayList<Data>();

You can then use it like this:
Data data = new Data();
//initialise data here
dat.add(data);

You would probably benefit from reading the Java Tutorial on Collections.

A:

List<Data> lsData = new ArrayList<Data>();

for(int i=0;i<5;i++)
{
    Data d = new Data();
    d.fname="fname";
    d.lname="lname";
    lsData.add(d);
}

Your Data class (Always make a Bean class to manage data)
public class Data
{
  public Data()
  {
  }
  public String fname,lname;
}

you can also get your data of particular position
String fname = lsData.get(2).fname;
String lname = lsData.get(2).lname;

