// Write master list of point of interest objects out as a CSV file public void saveCSVFile(String fileName, List<ParsedPointOfInterest> myList) throws IOException { FileOutputStream output = openFileOutput(fileName, MODE_PRIVATE); OutputStreamWriter writer = new OutputStreamWriter(output); CSVWriter csvWriter = new CSVWriter(writer); String columns[]; for (ParsedPointOfInterest poi : myList) { columns = poi.getColumns(); csvWriter.writeNext(columns); } writer.close(); csvWriter.flush(); csvWriter.close(); }
// If master list does exist then read the master list CSV file back in and print it out public List<ParsedPointOfInterest> loadCSVFile(String fileName) { List<ParsedPointOfInterest> myList = new ArrayList<ParsedPointOfInterest>(); FileInputStream input; try { input = openFileInput(fileName); InputStreamReader reader = new InputStreamReader(input); CSVReader csvReader = new CSVReader(reader); String columns[]; while ((columns = csvReader.readNext()) != null) { ParsedPointOfInterest poi = ParsedPointOfInterest.create(columns); myList.add(poi); } csvReader.close(); reader.close(); } catch (IOException e) { e.printStackTrace(); } return myList; }
// If master list does not exist then parse and load original template public List<ParsedPointOfInterest> loadTemplateFile(String fileName) { List<ParsedPointOfInterest> myList = new ArrayList<ParsedPointOfInterest>(); InputStream assetStream; try { assetStream = getAssets().open(fileName); InputStreamReader reader = new InputStreamReader(assetStream); CSVReader csvReader = new CSVReader(reader); String columns[]; while ((columns = csvReader.readNext()) != null) { ParsedPointOfInterest poi = ParsedPointOfInterest.create(columns); myList.add(poi); // LOOK INTO THIS!!!!!!!! } csvReader.close(); reader.close(); } catch (IOException e) { e.printStackTrace(); } return myList; }