In android to display file contains i wrote following code
BufferedReader myReader = null;
try
{
fIn = openFileInput("lost_test.txt");
myReader = new BufferedReader(new InputStreamReader(fIn));
}
catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
String aDataRow = "";
String aBuffer = "";
try
{
while ((aDataRow = myReader.readLine()) != null) {
aBuffer += aDataRow + "\n";
Toast.makeText(getBaseContext(),aBuffer+"\n",
Toast.LENGTH_SHORT).show();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Here i displayed the whole file contains but i want to display only First 2 records means Toast them individually in android how can i do this
1 Answer