从SD卡中的Andr​​oid读取特定文件 [英] reading a specific file from sdcard in android

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

问题描述

如何读取SD卡的特定文件。我已经推入SD卡文件通过DDMS,我想读它,虽然这样,但是这让我异常。有谁能够告诉我如何准确地指向在该文件?

我的code是这样的。

 字符串路径= Environment.getExternalStorageDirectory()getAbsolutePath()。
的FileInputStream的IStream =新的FileInputStream(路径);
 

解决方案

您正试图读取目录......你需要什么文件!做这样的事......那么,你可以根据需要读取该文件。

 文件DIR = Environment.getExternalStorageDirectory();
文件yourFile =新的文件(目录,路径/到/的/文件/内/ / sdcard.ext);
 

how to read a specific file from sdcard. i have pushed the file in sdcard through DDMS and i am trying to read it though this way but this give me exception. can anybody tell me how to point exactly on that file?

my code is this.

String path = Environment.getExternalStorageDirectory().getAbsolutePath();
FileInputStream iStream =  new FileInputStream(path);

解决方案

You are trying to read a directory... what you need is the file! Do something like this... then, you can read the file as you want.

File dir = Environment.getExternalStorageDirectory();
File yourFile = new File(dir, "path/to/the/file/inside/the/sdcard.ext");

这篇关于从SD卡中的Andr​​oid读取特定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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