Why is my SD Card not writable (Android)?

In the emulator I can't seem to write to the attached SDCard. The following code always spits out the "can't write root" log message, but not the "can't read root" one.

File routesRoot = Environment.getExternalStorageDirectory();
if (!routesRoot.canWrite())
    Log.v(getClass().getSimpleName(), "can't write root");
if (!routesRoot.canRead())
    Log.v(getClass().getSimpleName(), "can't read root");


Asked by: Elian162 | Posted: 25-01-2022

Answer 1

Check, and then double check that you have the WRITE_EXTERNAL_STORAGE permission.

Answered by: Sam830 | Posted: 26-02-2022

Similar questions

java - Drawing Nine Patch onto Canvas (Android)

I'm trying to draw a nine patch onto a Canvas object on the Android. What seems strange is that although I generated my nine patch using the draw9patch tool, the constructor for NinePatch requires an additional byte array called the "chunk" to construct the nine patch. Why isn't this simpler? What is the "chunk"? And if you have done this yourself, how did you go about it? Any help appreciated.

Edittext set for password with phone number input? (android)

How do I get a Edittext with both a phone input and the ability to hide the string. I know that android:inputType="textPassword" hides the string, while android:inputType="phone" brings up a dialpad interface. How to combine the two?

listview - How do I display 2 views in 1 activity (android)?

Suppose I have a webview open: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); main_webv = (WebView) findViewById(R.id.mainwebview); main_webv.setWebViewClient(new HelloWebViewClient()); main_webv.getSettings().setJavaScriptEnabled(true); main_webv.getSettings().setSupportZoom(false); main_webv.addJavascriptIn...

(Android) How to catch a "ring" event?

I'm clearly a newb, and I was wondering if anyone knows how I can detect a "ring" event on my cellphone through the android sdk? Generally I want to do something with the phone when it begins ringing! Any thoughts? If you want to simply point me to a page in the api documents that would be a good answer for me, I just don't know how to start my research!

Quick check on use of map api (android)

When you use the Google map api, it is not part of the Android SDK, and you have to mention it in your manifest xml file. Do you have to do anything to access the jar file containing the map api code? Or is that automatically present on the device or emulator, the way the SDK code is? Do you need put the map api jar file in your class path, either when compiling or when executing? Or is it kept somewhere ...

java - How do I use the session in WebView in my other stuff (Android)?

The user must login through the WebView. Of course, the session is for that WebView. But, what if I need to make REST API calls during my Android application? Those REST API calls need the session to be authenticated , otherwise those will not work. Is there any way I can attach the cookies of WebView into everything I do in Android?

java - Getting a variable out of a Public Void (Android)

I have this code: hubSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { final MediaPlayer mp2 = MediaPlayer.create(Textbox.this, R.raw.hero); mp2.start(); } public void onNothingSelected(AdapterView<?> parentView) { } });

java - Stopping and Play button for Audio (Android)

I have this problem, I have some audio I wish to play... And I have two buttons for it, 'Play' and 'Stop'... Problem is, after I press the stop button, and then press the Play button, nothing happens. -The stop button stops the song, but I want the Play button to play the song again (from the start) Here is my code: final MediaPlayer mp = MediaPlayer.create(this, R.raw.megadeth);

Shader as a drawable (Android)

How do I use obtain a drawable from a Shader (such as LinearGradient) so that I can use it as a background in my UI?

Get text from listview onclick (Android)

I am creating lists in my android app and would like to capture the text of the list item that is clicked but I want to do it in a seperate function so I only have to write the code once. And I want to be able to compare the string to another sting. What is the best way to do this?

Still can't find your answer? Check out these communities...

Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android