Android 如何访问目录中的文件

Android 如何访问目录中的文件,android,Android,您好,我是android编程新手,有人能告诉我如何访问目录中的文件吗?我正在使用Environment.getExternalStorageDirectory()方法?该方法只返回一个java.io.File,因此您应该能够使用标准java方法获取文件: String[] list(); //Returns an array of strings with the file names in the directory represented by this file. String[] li

您好,我是android编程新手,有人能告诉我如何访问目录中的文件吗?我正在使用Environment.getExternalStorageDirectory()方法?

该方法只返回一个java.io.File,因此您应该能够使用标准java方法获取文件:

String[] list(); //Returns an array of strings with the file names in the directory represented by this file. String[] list(FilenameFilter filter); //Gets a list of the files in the directory represented by this file. File[] listFiles(FileFilter filter); //Gets a list of the files in the directory represented by this file. 字符串[]列表()//返回一个字符串数组,其中包含此文件表示的目录中的文件名。 字符串[]列表(FilenameFilter过滤器)//获取此文件表示的目录中的文件列表。 文件[]列表文件(文件过滤器过滤器)//获取此文件表示的目录中的文件列表。
()

该方法只返回一个java.io.File,因此您应该能够使用标准java方法获取文件:

String[] list(); //Returns an array of strings with the file names in the directory represented by this file. String[] list(FilenameFilter filter); //Gets a list of the files in the directory represented by this file. File[] listFiles(FileFilter filter); //Gets a list of the files in the directory represented by this file. 字符串[]列表()//返回一个字符串数组,其中包含此文件表示的目录中的文件名。 字符串[]列表(FilenameFilter过滤器)//获取此文件表示的目录中的文件列表。 文件[]列表文件(文件过滤器过滤器)//获取此文件表示的目录中的文件列表。
)谢谢你。访问内部文件是否也一样,以及如何通过目录结构访问手机中的默认壁纸?我不知道。我从来没有在Android上使用过Java,只是在桌面上。但是如果墙纸没有隐藏在目录结构的某个地方,我会感到惊讶。好的,我如何像我使用的那样将文件添加到内部目录:Intent I=newintent(Intent.ACTION\u PICK,android.provider.MediaStore.Images.Media.internal\u CONTENT\u URI);获取文件,但当前未找到媒体,那么如何测试应用程序?谢谢。访问内部文件是否也一样,以及如何通过目录结构访问手机中的默认壁纸?我不知道。我从来没有在Android上使用过Java,只是在桌面上。但是如果墙纸没有隐藏在目录结构的某个地方,我会感到惊讶。好的,我如何像我使用的那样将文件添加到内部目录:Intent I=newintent(Intent.ACTION\u PICK,android.provider.MediaStore.Images.Media.internal\u CONTENT\u URI);获取文件,但当前未找到媒体,那么如何测试应用程序?