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

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

问题描述

如何从 sdcard 读取特定文件.我已经通过 DDMS 将文件推送到 sdcard 中,我试图通过这种方式读取它,但这给了我一个例外.谁能告诉我如何准确地指向那个文件?

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?

我的代码是这样的.

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");

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

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