如何从Android的内部存储中读取文件名 [英] How to read file names from Internal storage in Android

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

问题描述

我想从应用程序的默认内部存储文件夹中读取文件名,但是即使有一些文件,我也会得到一个大小为0的列表,我会使用以下内容读取文件名

I want to read the file names from the default internal storage folder of my app but even if there are some files I get a List of size 0 I use the following to read the file names

File dirFiles = Settings.this.getFilesDir();
    File list[] = dirFiles.listFiles();
    for( int i=0; i< list.length; i++)
    {
        myList.add( list[i].getName() );
    }

我在这里做错了什么?是我正确的道路吗?还是需要在其末尾加一个"/"?

What I am doing wrong here? is the path I get correct? or it needs to have a "/" at the end of it?

/data/data/com.compfrind.contacts/files

推荐答案

尝试这种方式

private File path = new File("/storage/" + "");


    File list[] = path.listFiles();
        for( int i=0; i< list.length; i++)
        {
            myList.add( list[i].getName() );
        }

还请查看回答

这篇关于如何从Android的内部存储中读取文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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