I have made a txt file with several lines. I want to display each line of the txt file in different textView. Only thing I have managed to do, is displaying the first line of the txt file. Maybe there is any other method how to display text from sd-card files?
My code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getTxtLine(2, R.id.textView1, txt);
public void getTxtLine(int textLine, int resId, File txtFile){
try {
FileInputStream fIn = new FileInputStream(txtFile);
BufferedReader myReader = new BufferedReader(
new InputStreamReader(fIn));
String aDataRow = "";
String aBuffer = "";
while ((aDataRow = myReader.readLine()) != null) {
aBuffer += aDataRow;
// byte buffer into a string
text = new String(aBuffer);
TextView text1 = (TextView)findViewById(resId);
text1.setText(text);
}
} catch (Exception e) {
}
http://stackoverflow.com/questions/2902689/how-can-i-read-a-text-file-from-the-sd-card-in-android – TeeTracker Aug 13 '13 at 15:52