try{Khi chạy bạn nhớ bật Logcat để xem kết quả. Đoạn code đặt ngay trong hàm onCreate() nhé.
File f = new File(Environment.getExternalStorageDirectory()+"/test.txt");
fileIS = new FileInputStream(f);
BufferedReader buf = new BufferedReader(new InputStreamReader(fileIS));
String readString = new String();
//đọc theo từng dòng
while((readString = buf.readLine())!= null){
// hiển thị ra LOGCAT
Log.d("line: ", readString);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
AndroidWorld - Diễn đàn Android Việt Nam, forum Android, nơi trao đổi thông tin kiến thức về lập trình Android, phần mềm Android, rom cook điện thoại Android, tin tức công nghệ
Monday, April 15, 2013
Đọc nội dung file .txt trong sdcard [ For Newbie ]
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment