Unable to read / write on SD card in Android

Can anyone help with this problem

when i try to execute this 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"); 

at startup, the program cannot write / read

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

+4
source share
2 answers

Do you have this in your manifest.xml ??

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

From the android SDK ver 4, you must specify this in your manifest file in order to grant permissions.

+7
source

If you use your phone, make sure that your SD card is not installed on your computer. Check also if you use the Android SDK from 1.5

0
source

Source: https://habr.com/ru/post/1315226/


All Articles