I have to take the text file from SD card in a folder and display them in textView. I am using this code
if(file!=null){
File list[] = file.listFiles();
Log.d("file size>>",""+file.length());
if(list!=null){
for( int i=0; i< list.length; i++)
{
Log.d(">>>>",""+list[i].getName());
if(list[i].isFile() && list[i].getName().endsWith(".txt")) {
myList.add(list[i]);
Log.d("myList size>>",""+myList.size());
try {
FileInputStream fIn = new FileInputStream(list[i]);
BufferedReader myReader = new BufferedReader(new InputStreamReader(fIn));
while ((aDataRow = myReader.readLine()) != null) {
aBuffer += aDataRow + "\n";
}
abc = aBuffer;
Log.d("log valuee>>",abc);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
abc is the string variable in which I am saving the value of each file but it prints the repetitive data every time loop runs. Other Logs are printing accurate data