What is emulated storage?

Emulated storage, also known as virtual storage, refers to a method of simulating storage devices within a software environment, such as hard drives or solid-state drives. This technique allows for the creation of virtual storage devices that can be managed and accessed as if they were real physical devices.

Emulated storage is often used in virtualization and cloud computing environments, where multiple virtual machines or instances share resources on a single physical host. By emulating storage devices, each virtual machine can be given its own dedicated storage space that appears as a separate device, even though it is part of a larger physical storage system.

There are different types of emulated storage, such as:

  1. File-based storage: Virtual storage devices are created as files on the host system’s file system. Each virtual device is stored as an individual file, which can be easily managed, transferred, or backed up.
  2. Block-based storage: Virtual storage devices are created by abstracting and virtualizing physical storage devices. This method allows for better performance and flexibility compared to file-based storage, as the virtual devices can be managed at the block level, similar to how physical storage devices operate.

Emulated storage provides several benefits, including resource optimization, flexibility, cost savings, and ease of management. However, it can also introduce some performance overhead, as the emulation process adds an extra layer of complexity to the storage system.

If you have an Android device, you may have noticed a folder called /storage/emulated/0/ in your file manager. What is this folder, and what does it store?

Emulated storage is a type of storage that appears on your device as a separate partition from internal storage. It is built into the Android operating system and allows you to create virtual SD cards to expand your device’s storage.

Emulated storage is the standard storage location in an Android device to store a user’s data. It is used by Android applications to store apps’ sensitive data to keep it safe from accidental deletes by the user. For example, by default, photos, videos, music, documents, and downloads are stored in emulated storage.

Emulated storage is also used to provide compatibility with older apps that expect a removable SD card as their primary storage location. Emulated storage creates a virtual SD card that mimics the behavior of a physical one without actually requiring one.

How does emulated storage work?

Emulated storage exposes a portion of internal storage through an emulation layer and has been available since Android 3.0. The emulation layer uses FUSE (Filesystem in Userspace) to create a virtual filesystem that maps files and directories to their actual locations on internal storage.

The actual files are located in the filesystem in /data/media, which is then mounted to /storage/emulated/0 (and often other mount points). The mountpoint/storage/emulated/0 is also symlinked (symbolically linked) to /sdcard for convenience.

The advantage of emulated storage is that it allows users to access their data across multiple user profiles and runtime environments without duplicating or moving files around. It also enables apps to manage their package-specific directories on external storage without requiring they hold the broad WRITE_EXTERNAL_STORAGE permission.

What are the limitations of emulated storage?

Emulated storage has some limitations that users should be aware of. For instance:

  • Emulated storage does not support FAT32 features such as short file names, timestamps, or hidden attributes.
  • Emulated storage does not allow users to unmount or eject the virtual SD card like they can with a physical one.
  • Emulated storage may consume more space than necessary due to file system overhead and fragmentation.
  • Emulated storage may perform slower than direct access to internal or external memory due to the extra abstraction layer.

How can I access emulated storage?

Emulated storage is a feature of Android that allows apps to store data on a virtual internal storage partition without requiring special permissions. Emulated storage is also known as /storage/emulated/0/ or /sdcard/, depending on the Android version and device model.

Emulated storage has several advantages over using physical media, such as SD cards or USB drives, for storing app data. For example:

  • Emulated storage is encrypted and formatted to behave like internal storage, which means it is more secure and reliable than external storage.
  • Emulated storage does not depend on the availability or compatibility of physical media, which may be removed, damaged, or corrupted.
  • Emulated storage can store all app data types, including private files, media collections, and adoptable storage.

However, emulated storage also has some limitations and challenges that developers must be aware of. For instance:

  • Emulated storage is exposed through an emulation layer that may affect the performance and compatibility of some apps or file operations.
  • Emulated storage is subject to the same quota and restrictions as internal storage, which means it may run out of space or be inaccessible by some apps.
  • Emulated storage may have different paths and mount points depending on the Android version and device model, which may cause confusion or errors for some apps.

To access emulated storage programmatically from your app, you need to use the appropriate APIs and methods provided by Android. Depending on your target SDK level and use case, you may need to request different permissions or follow different guidelines.

You can access emulated storage using any file manager app that supports it. You can also use adb shell commands or terminal emulator apps if you have root access.

Here are some general steps to access emulated storage from your app:

  • 1. Determine the path of emulated storage for your device. You can use methods such as Environment.getExternalStorageDirectory() or Context.getExternalFilesDir() to get a File object representing emulated storage. Alternatively, you can use URIs such as content://media/external/ or content://com. Android. externalstorage.documents/ to access emulated storage through a ContentResolver.
  • 2. Check if you have permission to read or write to emulated storage. If your target SDK level is lower than 29 (Android 10), you need to request READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE permissions in your manifest file. Suppose your target SDK level is 29 (Android 10) or higher. In that case, you need to either opt out of scoped storage by setting Android:requestLegacyExternalStorage=”true” in your manifest file (not recommended) or use scoped storage APIs such as MediaStore or Storage Access Framework (SAF) to access specific types of files on emulated storage without requiring any permissions.
  • 3. Perform file operations on emulated storage using standard Java I/O classes such as
    • FileInputStream, FileOutputStream, FileReader,
    • FileWriter, etc., or using ContentResolver methods such as openInputStream(),
    • openOutputStream(),
    • query(),
    • insert(),
    • update(),
    • delete(), etc., depending on whether you are using File objects
    • or URIs.

For more information about accessing emulated storage from your app, please refer to these official Android documentation pages:

We will be happy to hear your thoughts

      Leave a reply

      Android Library
      Enable registration in settings - general