If you need to save the List as Text, work with an ForEach Loop or Iterator, run over all Elements and give every String to the FileWriter and save it as Text on your SD Card.
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ListDemo {
public static void main(String[] args) {
FileWriter fileWriter = null;
try {
List<String> lista = new ArrayList<>();
int i= 0;
int j=0;
int distance = 100;
lista.add("Kommunikál: " +(i+1)+ " -> " +(j+1)+ " && " +(j+1)+ " -> " +(i+1)+ " - " + distance + " m\n");
lista.add("Kommunikál: " +(i+1)+ " -> " +(j+1)+ " && " +(j+1)+ " -> " +(i+1)+ " - " + distance + " m");
fileWriter = new FileWriter(new File("listOutput.txt"));
for(String s : lista)
fileWriter.write(s);
fileWriter.flush();
} catch (IOException ex) {
Logger.getLogger(ListDemo.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
fileWriter.close();
} catch (IOException ex) {
Logger.getLogger(ListDemo.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
If you use an ObjectOutputStream, you can write primitive Types and also complex Java Objects to an file and you could read this object back from file and reconstitute it.
Patrick