Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>On some phones, as the <a href="http://developer.android.com/reference/android/os/Environment.html#getExternalStorageState%28%29" rel="nofollow">documentation</a> suggests, the word <em>external</em> is not to be taken all too serious:</p> <blockquote> <p>Note: <strong>don't be confused by the word "external" here.</strong> This directory can better be thought as media/shared storage. <strong>It is a filesystem that can hold a relatively large amount of data</strong> and that is shared across all applications (does not enforce permissions). <strong>Traditionally this is an SD card, but it may also be implemented as built-in storage</strong> in a device that is distinct from the protected internal storage and can be mounted as a filesystem on a computer.</p> </blockquote> <p>You can check if the storage is <em>really</em> external or not, using the <a href="http://developer.android.com/reference/android/os/Environment.html#isExternalStorageRemovable%28%29" rel="nofollow"><code>Environment.isExternalStorageRemovable()</code>-method</a>. If it's not removable, you should always be able to write to it (given that you have the permissions declared).</p> <p>If it <em>is</em> however removable, you'll need to check it's current state with <a href="http://developer.android.com/reference/android/os/Environment.html#getExternalStorageState%28%29" rel="nofollow"><code>Environment.getExternalStorageState()</code></a>. Here's a quick example of how to use it:</p> <pre><code>String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // We can read and write! } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { // Mounted read only... } else { // Something is wrong... } </code></pre> <p>So in these cases, you can write to the external storage.</p> <hr> <p><strong>Important</strong>: As the documentation specifies at multiple points, the above methods work for the <strong><em>primary</em></strong> external storage. Some devices (like the Motorola Xoom) have both an internal "external" storage, and an SD-Card.</p> <p>There seems to be no "generalized" way to access the "<em>secondary</em> external storage" on such devices, although there is a <a href="http://source.android.com/tech/storage/" rel="nofollow">standard</a> now, introduced with Android 4.2</p> <blockquote> <p>Devices may contain multiple instances of external storage, but <strong>currently only the primary external storage is exposed to developers through API.</strong></p> <p>[...]</p> <p>Starting in Android 4.2, devices can support multiple users, and <strong>external storage must meet the following constraints</strong>:</p> <ul> <li>[...]</li> <li><strong>Secondary external storage must not be writable by apps.</strong></li> </ul> </blockquote> <p>It seems to depend on the vendor which storage (internal or <em>real</em> external) is considered the primary one. Not much you can do here (without things getting messy...)</p> <hr> <p>If there is no external storage present, you can use your applications <a href="http://developer.android.com/guide/topics/data/data-storage.html#filesInternal" rel="nofollow">Internal Storage</a>, or the caching directory, depending on what kind of data you're storing. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload