FileDocCategorySizeDatePackage
AndroidLocation.javaAPI DocAndroid 1.5 API3312Wed May 06 22:41:08 BST 2009com.android.prefs

AndroidLocation

public final class AndroidLocation extends Object
Manages the location of the android files (including emulator files, ddms config, debug keystore)

Fields Summary
public static final String
FOLDER_AVD
Virtual Device folder inside the path returned by {@link #getFolder()}
private static String
sPrefsLocation
Constructors Summary
Methods Summary
private static java.lang.StringfindValidPath(java.lang.String names)
Checks a list of system properties and/or system environment variables for validity, and existing director, and returns the first one.

param
names
return
the content of the first property/variable.

        for (String name : names) {
            String path;
            if (name.indexOf('.") != -1) {
                path = System.getProperty(name);
            } else {
                path = System.getenv(name);
            }

            if (path != null) {
                File f = new File(path);
                if (f.isDirectory()) {
                    return path;
                }
            }
        }
        
        return null;
    
public static final java.lang.StringgetFolder()
Returns the folder used to store android related files.

return
an OS specific path, terminated by a separator.
throws
AndroidLocationException

    
                              
           
        if (sPrefsLocation == null) {
            String home = findValidPath("ANDROID_SDK_HOME", "user.home", "HOME");
            
            // if the above failed, we throw an exception.
            if (home == null) {
                throw new AndroidLocationException(
                        "Unable to get the home directory. Make sure the user.home property is set up");
            } else {
                sPrefsLocation = home + File.separator + ".android" + File.separator;

                // make sure the folder exists!
                File f = new File(sPrefsLocation);
                if (f.exists() == false) {
                    f.mkdir();
                } else if (f.isFile()) {
                    throw new AndroidLocationException(sPrefsLocation +
                            " is not a directory! This is required to run Android tools.");
                }
            }
        }

        return sPrefsLocation;