我想从android的系统文件夹中读取“build.prop”文件,并将其作为字符串显示在textview中。但是,我的应用程序正在运行,然后强制关闭..
我的代码:
public void selfDestruct(View view) throws IOException {
File path = getApplicationContext().getFilesDir();
File file = new File(path, "build.prop");
int length = (int) file.length();
byte[] bytes = new byte[length];
FileInputStream in = new FileInputStream(file);
try {
in.read(bytes);
} finally {
in.close();
}
String contents = new String(bytes);
textView.setText(contents);
}