我如何读取内部存储的文件内容-Android APP [英] How do I read the file content from the Internal storage -Android APP
本文介绍了我如何读取内部存储的文件内容-Android APP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
荫一newbie-与Android合作,
Iam a newbie- working with Android,
文件中的位置数据/数据/ MyApp的/文件/ hello.txt的已创建
file is already created in the location data/data/myapp/files/hello.txt
文件的内容是:你好
推荐答案
看看这个如何使用Android的存储器<一href="http://developer.android.com/guide/topics/data/data-storage.html#filesInternal">http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
Take a look this how to use storages in android http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
要读取内部存储的数据,你需要你的应用程序文件夹和读取从这里含量
To read data from internal storage you need your app files folder and read content from here
String yourFilePath = context.getFilesDir() + "/" + "hello.txt";
File yourFile = new File( yourFilePath );
你也可以使用这个方法
Also you can use this approach
FileInputStream fis = context.openFileInput("hello.txt", Context.MODE_PRIVATE);
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader bufferedReader = new BufferedReader(isr);
StringBuilder sb = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
sb.append(line);
}
这篇关于我如何读取内部存储的文件内容-Android APP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文