我需要阅读从手机memory.How读取文件中的文件?谁能帮助我?
I need to read the file from the phone memory.How read file ?can anyone help me??
下面介绍如何在一个文件中写入。
Here's how to write in a file..
FileOutputStream fos = openFileOutput("urls.txt", Context.MODE_PRIVATE);
fos.write("Alex".getBytes());
fos.close();
下面是如何读取该文件:
Here's how to read that file:
FileInputStream fis = openFileInput("urls.txt");
int c;
while((c=fis.read())!=-1)
{
k += (char)c;
}
fis.close();
字符串-k将包含ANKIT作为一个字符串。
String k will contain "Ankit" as a string.
你..文件urls.txt被形成在手机内存中的心灵,你不能访问该文件在您的项目作为一种资源。
Mind you.. the file "urls.txt" gets formed in the phone memory, you cannot access that file in your project as a resource.
有关更多信息,请参见:的http://developer.android.com/guide/topics/data/data-storage.html#filesInternal
For more information see: http://developer.android.com/guide/topics/data/data-storage.html#filesInternal