如何从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() );
        }

还请查看回答