Comprehensive Guide to Customizing Android Virtual Device Storage Locations

Nov 26, 2025 · Programming · 7 views · 7.8

Keywords: Android Virtual Device | Environment Variable Configuration | AVD Storage Location

Abstract: This article provides a detailed explanation of how to customize the default storage location for Android Virtual Devices (AVDs) through environment variable configuration. Focusing on Windows system users, it covers the setup methods for ANDROID_SDK_HOME and ANDROID_AVD_HOME environment variables, including both manual configuration and tool-assisted approaches. The article also delves into AVD directory structure analysis, configuration file migration considerations, and environment variable priority relationships, offering developers a complete storage customization solution.

Overview of Android Virtual Device Storage Locations

In the Android development environment, Android Virtual Devices (AVDs) are by default stored in the .android folder within the user's home directory. For Windows XP systems, the default path is Documents and Settings\<user>\.android; for newer Windows versions, the path is typically Users\<user>\.android. This default configuration may not be ideal in certain scenarios, particularly when developers wish to consolidate all development-related files in specific partitions or directories.

Environment Variable Configuration Methods

The most effective approach to change AVD storage location is by setting specific environment variables. According to official documentation and practical experience, this primarily involves the following two environment variables:

ANDROID_SDK_HOME Environment Variable

This is the most commonly used configuration method. By setting the ANDROID_SDK_HOME environment variable, you can specify the root directory used by AVD Manager. The .android folder will be created within this directory, containing all AVD-related files.

Configuration steps for Windows 7 and later systems:

  1. Open Start Menu and navigate to Control Panel
  2. Select "System" then click "Advanced system settings" on the left
  3. Click "Environment Variables" in the System Properties window
  4. Click "New" in the User variables section
  5. Set variable name as ANDROID_SDK_HOME
  6. Set variable value to your chosen directory path
  7. Click "OK" to save all settings

Configuration example:

Variable name: ANDROID_SDK_HOME
Variable value: D:\Android\Development

ANDROID_AVD_HOME Environment Variable

According to Android official documentation, you can also set the ANDROID_AVD_HOME environment variable to specifically control AVD file storage location. This variable has higher priority, and when set, the emulator will preferentially use this path.

Environment variable search order:

  1. $ANDROID_AVD_HOME
  2. $ANDROID_SDK_HOME/.android/avd/
  3. $HOME/.android/avd/

Configuration File Migration

After changing AVD storage location, if existing AVD configurations are present, file migration is necessary:

  1. Copy all contents from the original .android/avd/ directory to the new target location
  2. Modify path references in each AVD's corresponding INI files
  3. Ensure correct file permission settings

During migration, maintain directory structure integrity, particularly the correspondence between .avd and .ini files.

Tool-Assisted Configuration

Beyond manual environment variable setting, specialized tools can simplify the configuration process. For example, Rapid Environment Editor provides a graphical interface for managing system environment variables, particularly suitable for users unfamiliar with command-line operations.

Advantages of using tools:

AVD Directory Structure Analysis

Understanding AVD directory structure facilitates better virtual device management:

.android/
├── avd/                    # AVD configuration file directory
│   ├── <avd_name>.avd/    # Specific AVD data directory
│   └── <avd_name>.ini     # AVD configuration file
├── cache/                  # Cache files
├── ddms.cfg               # DDMS configuration
└── repositories.cfg       # Repository configuration

Each AVD consists of two main files: INI configuration file and data directory. The INI file contains basic AVD configuration information, while the .avd directory stores actual virtual device data, including system images, user data, etc.

Configuration Verification and Testing

After completing environment variable configuration, verification is necessary:

  1. Open Command Prompt, enter echo %ANDROID_SDK_HOME% (or echo %ANDROID_AVD_HOME%) to confirm correct variable setting
  2. Start Android Studio or AVD Manager
  3. Create a new AVD, check if files are generated in the specified location
  4. Start the emulator, verify normal functionality

If issues occur, check:

Best Practice Recommendations

Based on practical development experience, the following best practices are recommended:

By properly configuring AVD storage locations, developers can not only better organize their development environment but also improve development efficiency and management convenience.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.