When you create Android applications that require to use external storage of the phone to store files, you will need to create folders in the phone' external storage. In Android, you can get the path of the external storage by using the getExternalStorageDirectory() method of the Environment class. Then you can use the mkdir() or mkdirs() method of the File class to create a folder in the external storage. If the parent folder of the folder to be created already exists, you will use the mkdir() method. Otherwise, you must use the mkdirs() method. The mkdir() method will only create the bottom most folder. Your folder won't be created if its parent folder doesn't exist in the directory structure. You can use the exists() method of the File class to check whether the folder to be created already exists before calling the mkdir() or mkdirs() method. It returns true if the folder already exists. Otherwise it returns false. The mkdir() or mkdirs() method returns true if the folder is successfully created. Otherwise, it returns false.
Posted by: Dara | post date: 05-27-2014 | Subject: Android Apps Development
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: