You can read in a flat file from an SD card with 1 insert for each line and scroll through this file.
Here is an example in which I read the file and add ContactItem to my contact list:
public ArrayList<ContactItem> readInputFile(Context context, String filename) {
String text = null;
BufferedReader reader = null;
ArrayList<ContactItem> contact_list = new ArrayList<ContactItem>();
contact_list.clear();
try {
reader = new BufferedReader(new FileReader(filename));
while (((text = reader.readLine()) != null)) {
if (!(text.length() > 1024)) {
ContactItem c = new ContactItem(text);
if (c.getIsValid()) {
contact_list.add(c);
}
}
}
} catch (FileNotFoundException e) {
Toast.makeText(context, R.string.error_fileNotFound, 1).show();
e.printStackTrace();
} catch (IOException e) {
Toast.makeText(context, R.string.error_ioException, 1).show();
e.printStackTrace();
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (IOException e) {
Toast.makeText(context, R.string.error_generalFailure, 1).show();
e.printStackTrace();
}
}
return contact_list;
}
source
share