Advertisement
Guest User

Untitled

a guest
Apr 25th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. File file = new File(Constants.ROOT_PATH);
  2. int i = 0;
  3. while (!file.isDirectory() && !file.mkdirs()) {
  4. file.mkdirs();
  5. Log.e("mkdirs", "" + i++);
  6. }
  7.  
  8. String root = Environment.getExternalStorageDirectory().toString();
  9. File myDir = new File(root + "/hello_world");
  10. myDir.mkdirs();
  11.  
  12. File file = new File (myDir, file_name);
  13. if (file.exists ())
  14. // file exist
  15. else
  16. // file not exist
  17.  
  18. if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
  19. {
  20. if (DEBUG) {Log.d(TAG, "createSoundDir: media mounted");} //$NON-NLS-1$
  21. File externalStorage = Environment.getExternalStorageDirectory();
  22. if (externalStorage != null)
  23. {
  24. String externalStoragePath = externalStorage.getAbsolutePath();
  25. File soundPathDir = new File(externalStoragePath + File.separator + "Hello_World"); //$NON-NLS-1$
  26.  
  27. if (soundPathDir.isDirectory() || soundPathDir.mkdirs())
  28. {
  29. String soundPath = soundPathDir.getAbsolutePath() + File.separator;
  30. if (DEBUG) {Log.d(TAG, "soundPath = " + soundPath);} //$NON-NLS-1$
  31.  
  32. }
  33. }
  34. }
  35.  
  36. public static final String ROOT_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Hello_World/";
  37.  
  38. File file = new File(Constants.ROOT_PATH);
  39. int i = 0;
  40.  
  41. if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
  42. if(!file.exists()) {
  43. file.mkdir();
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement