如何读取手机内存中的Andr​​oid文件? [英] how to read file from the phone memory in android?

查看:113
本文介绍了如何读取手机内存中的Andr​​oid文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要阅读从手机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

这篇关于如何读取手机内存中的Andr​​oid文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆