android sd卡中的文本文件 [英] text files in android sd card

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

问题描述

如何获取存储在android SD卡中的文本文件列表

how to get list of text files stored in android Sd card

推荐答案

您可以尝试执行以下操作;

You could try something like this;

File files[] = Environment.getExternalStorageDirectory().listFiles();
for(File file : files) {
  String filePath = file.getAbsolutePath();
}



然后,您可以使用适用于您的应用程序的任何逻辑遍历那些条目.

希望这会有所帮助,
弗雷德里克(Fredrik)



Then you can traverse those entries using whatever logic applies to your application.

Hope this helps,
Fredrik


在下面尝试获取所有txt文件

try below to get all txt files

File files[] = Environment.getExternalStorageDirectory().listFiles(
		new FilenameFilter() {
			@Override
			public boolean accept(File dir, String filename) {
					return ((filename.endsWith(".txt")));
			}
		});


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

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