tags:

views:

61

answers:

1

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  A: 

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 )

Curtis
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?
pranay
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.
Curtis
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?
pranay