代码如下:
// 读取sdcard文件
private void sdcardRead(){
String fileName = "/sdcard/my_sdcard.txt";// assets下文件
//String fileName = "/sdcard/test/my_sdcard_test.txt";// sdcard下子目录文件
String ret = "";
try {
FileInputStream fis = new FileInputStream(fileName);
int len = fis.available();
byte []buffer = new byte[len];
fis.read(buffer);
ret = EncodingUtils.getString(buffer, "UTF-8");
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
tvTXT.setText(ret);
}