4

Can any one help in that problem

when i try that code

File routesRoot = Environment.getExternalStorageDirectory();
            if (!routesRoot.canWrite())
                System.out.println("can't write root");
            if (!routesRoot.canRead())
                System.out.println("can't read root");

when run program both can't write /read occure

I have set permission to access sdcard what is the problem ??

Ahmed Salem
  • 1,687
  • 22
  • 26
  • 1
    I'm stuck with the same issue. `File sdCard = Environment.getExternalStorageDirectory(); Toast.makeText(getApplicationContext(), sdCard.canRead()? "READ PERMISSIONS":"NO READ PERMISSIONS", Toast.LENGTH_SHORT).show();` I'm using Android 1.5 and I'm really stuck over here. can someone help please. – Tirtha Jan 10 '12 at 13:54
  • Sorry, i got my question answered. i was trying to run the application while my phone was plugged in to the computer through USB. And phone will not be able to read it when it is plugged in to the USB http://stackoverflow.com/a/3476870/1099211 – Tirtha Jan 10 '12 at 14:47

2 Answers2

7

Do you have this in your manifest.xml??

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

From android SDK ver 4, you have to specify this in your manifest file to give the permissions.

Teja Kantamneni
  • 17,402
  • 12
  • 56
  • 86
0

If you are using your phone, make sure that your SD card is not mounted on your computer Check also if you are using android SDK over 1.5

himura
  • 1,555
  • 3
  • 19
  • 30