让Android手机的内容 [英] get the content of android mobile

查看:158
本文介绍了让Android手机的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读的移动像子目录目录的内容,以及其在android手机的可用文件。

i would like to read the content of mobile like directories with sub directories as well as files which are available in android phone.

我已经实现了让Android手机的内容如下应用程序

i have implemented an application for get the content of android phone as follows

Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
// Browse in the following folder.
Uri startDir = Uri.fromFile(new File("/sdcard/"));
// Files and directories
intent.setDataAndType(startDir, "vnd.android.cursor.dir/lysesoft.andexplorer.file");
// Optional filtering on file extension.
intent.putExtra("browser_filter_extension_whitelist", "*.xml,*.txt,*.jpg,*.mp3,*.zip");
// Title
intent.putExtra("explorer_title", "Open File...");
// Optional font scale
intent.putExtra("browser_list_fontscale", "120%");
// Optional 0=simple list, 1 = list with filename and size, 2 = list with filename, size and date.
intent.putExtra("browser_list_layout", "2");
startActivityForResult(intent, OPEN_FILE_REQUEST);

如果我用上述的方式我收到强制关闭错误的:

if i use above shown way i am getting force close error as:

05-26 18:20:02.917:ERROR / AndroidRuntime(26867):android.content.ActivityNotFoundException:无活动处理意向{行为= android.intent.action.PICK DAT =文件:// / SD卡(典型值)= vnd.android.cursor.dir / lysesoft.andexplorer.file(有临时演员)}

在这里,我怎么能解决部队密切错误的问题?有没有另一种方式来获得的android手机的内容?

here how can i resolve the force close error issue? is there any another way to get the content of android phone?

请任何机构可以帮助我

在此先感谢

推荐答案

尝试

final File dir = context.getFilesDir();
for (final File file : dir.listFiles()) {
    ...
}

final File dir = new File("/sdcard"); 
for(final File file : dir.listFiles()){ 
    ...
}

这篇关于让Android手机的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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