2

I have an Xperia Neo V that does not have any internal storage - only an SD card as external storage, while the Galaxy S3 has both internal and external storage.

When using this function Environment.getExternalStorageDirectory(); I can access files only on internal storage(S3) but there is no problem with Xperia Neo V.

How can I access files on both internal and external storage?

RocketDonkey
  • 36,383
  • 7
  • 80
  • 84
user1778783
  • 21
  • 1
  • 2

1 Answers1

1

I have an Xperia Neo V that does not have any internal storage

All Android devices have internal storage, including the Xperia Neo V. Internal storage is where the OS and application data is stored -- without it, your phone would not work.

Presumably, you are having problems with the words "external" and "removable". In Android terms, "external" means "can be accessed by the user independently by plugging a USB cable between the device and a host computer". All Android devices have external storage; whether that storage is removable or not varies.

So, in the case of an Xperia Neo V, you have both internal and external storage, and the external storage is represented by a removable SD card.

When using this function Environment.getExternalStorageDirectory(); I can access files only on internal storage(S3) but there is no problem with Xperia Neo V.

That is because getExternalStorageDirectory() returns the external storage directory for that device.

How can I access files on both internal and external storage?

Use getExternalStorageDirectory() to get access to external storage. Use getFilesDir() to get at your app's portion of internal storage.

For devices that have multiple forms of external storage -- such as your Galaxy S3 -- the Android SDK only supports accessing whichever one of those is provided by getExternalStorageDirectory().

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Interesting. So then, if you remove the sdcard and take photos, then the photos will be stored on the non-removable external storage? Now, if you put the sdcard back in, will you lose access to those photos until the card us removed? Or how does that work? – trusktr Jan 12 '13 at 21:23
  • 1
    @trusktr: "So then, if you remove the sdcard and take photos, then the photos will be stored on the non-removable external storage?" -- you would have to ask the authors of the specific camera app. "Now, if you put the sdcard back in, will you lose access to those photos until the card us removed? Or how does that work?" -- again, you would have to ask the authors of the specific camera app. There are thousands of camera apps, so this will take you some time. – CommonsWare Jan 12 '13 at 21:40
  • Well let's consider a camera app that uses `Environment.getExternalStorageDirectory()` to set it's working path. The app creates a DCIM folder in the directory returned by that method and stores all photos in DCIM. If the sdcard is present, then the DCIM folder will be on the sdcard. If the sdcard is removed, then a new DCIM folder would be created somewhere in the internal "external storage". When the sdcard is put back into the phone, there will now be two DCIM folders in the device. Will one folder be recognized while the other one ignored? – trusktr Jan 13 '13 at 00:05
  • 1
    @trusktr: "If the sdcard is removed, then a new DCIM folder would be created somewhere in the internal "external storage"." -- there is no "internal external storage" in your scenario, by your own admission. You said the external storage was a removable card, and therefore external storage is **only** on the removable card. Android has *precisely **one** external storage location* -- whatever is returned by `getExternalStorageDirectory()` and related methods. Anything beyond that is beyond the Android SDK. – CommonsWare Jan 13 '13 at 00:07
  • Is it not possible for phones to have two external storage locations? I thought I read somewhere that that galaxy s3 has two locations so if you remove the sdcard then external storage still works. That's the type of scenario I was thinking of. Is that possible? – trusktr Jan 13 '13 at 00:42
  • 1
    @trusktr: It is not possible for `getExternalStorageLocation()` to return two values. AFAIK, on the S3, the removable card is never "external storage". Certainly, few modern Android devices have removable storage be the "external storage" for the device. It's been that way since mid-2010. – CommonsWare Jan 13 '13 at 01:31
  • Both my devices has 2 external storages: sdcard0 and sdcard1 (onboard memory and removable), and internal storage, where apps&system are stored – Tertium Sep 24 '13 at 18:13