The main way is Read File like this:
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
Get title of the columns:
String dataA = br.readLine();
String[] eachLineA = dataA.split(",");
Read line by line :
while ((dataA = br.readLine()) != null)
Split and Remove " from each cell,
fitData.add(eachLineA[i].replaceAll("\"", ""));
Finally add to database
myDb.addHandler(fitData.get(0), fitData.get(1), fitData.get(2), fitData.get(3), fitData.get(4));
This is a while loop:
while ((dataA = br.readLine()) != null) {
while (way && dataA != null) {
eachLineA = dataA.split(",");//
if (eachLineA.length < leA && fitData.size() < leA) {
way = true;
dataA = br.readLine();
} else way = false;
for (int i = 1; i <= eachLineA.length - 1; i++) {
fitData.add(eachLineA[i].replaceAll("\"", ""));
Log.i("Tag", "N:" + i);
}
}
myDb.addHandler(
fitData.get(0), fitData.get(1), fitData.get(2), fitData.get(3), fitData.get(4)
);
fitData.clear();
way = true;
}