0

I'm trying to create folder on the SDCard on Android 2.3 device:

final File downloadFolder = new File(FILES_PATH);
        if (!downloadFolder.exists()) {
            Log.i(TAG, "Creating tmp directory: " + downloadFolder.mkdirs());
        } 

And mkdirs() returns false. FILES_PATH is the same that getExternalStorage() returns - /mnt/sdcard/.tmp/ SD card is writable from the cli with root. Permission:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.venturezlab.tvupdater"
          android:versionCode="1"
          android:versionName="1.0">
    <uses-sdk android:minSdkVersion="10"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Why?

artem
  • 16,382
  • 34
  • 113
  • 189

2 Answers2

1

Try mkdir() instead of mkdirs()

Jeremy D
  • 4,787
  • 1
  • 31
  • 38
0

Try this

final File downloadFolder = new File(Environment.getExternalStorageDirectory()+"/.tmp"); 
Sardor Dushamov
  • 1,665
  • 3
  • 17
  • 44
  • Sorry, I made a mistake in the question. FILES_PATH is /mnt/sdcard/.tmp – artem Nov 12 '12 at 11:10
  • change FILES_PATH to Environment.getExternalStorageDirectory() – Sardor Dushamov Nov 12 '12 at 11:12
  • I've checked, /mnt/sdcard is the return value of Environment.getExternalStorageDirectory(). And it has link /sdcard/ – artem Nov 12 '12 at 11:16
  • But, have you tried it with Environment.getExternalStorageDirectory? – Jeremy D Nov 12 '12 at 15:51
  • Yes, first of all I tried this method, it returned the string that is exactly FILES_PATH. I use constant because this software is only for one specific device and I'm sure that the path will never change. – artem Nov 13 '12 at 19:19