【发布时间】:2010-07-23 08:45:04
【问题描述】:
我需要从手机内存中读取文件。如何读取文件?谁能帮助我?
【问题讨论】:
标签: android
我需要从手机内存中读取文件。如何读取文件?谁能帮助我?
【问题讨论】:
标签: android
以下是如何写入文件..
FileOutputStream fos = openFileOutput("urls.txt", Context.MODE_PRIVATE);
fos.write("Alex".getBytes());
fos.close();
读取该文件的方法如下:
FileInputStream fis = openFileInput("urls.txt");
int c;
while((c=fis.read())!=-1)
{
k += (char)c;
}
fis.close();
字符串 k 将包含“Ankit”作为字符串。
请注意..文件“urls.txt”在手机内存中形成,您无法在项目中将该文件作为资源访问。
欲了解更多信息,请参阅:http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
【讨论】:
(通过谷歌搜索)
从内部存储读取文件:
参考:http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
【讨论】: