hi i am new to android programming, can someone please tell me how to get access to the files in a directory , i am using Environment.getExternalStorageDirectory() method?
1 Answer
That method just returns a java.io.File, so you should be able to get the files using the standard Java methods:
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.
( http://developer.android.com/reference/java/io/File.html )
3 Comments
pranay
thanks for that. Will the be same for accessing the internal file and also how can i access the default wallpapers present in the phone via a directory structure?
Curtis
That, I don't know. I've never actually used Java on Android, just on the desktop. But I'd be surprised if the wallpapers aren't hidden in the directory structure somewhere.
pranay
ok and how do i add files to a internal directory like i am using : Intent i =new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI); to get the files but currently it shows no media found , so how do i test the app?