FileDocCategorySizeDatePackage
StorageVolume.javaAPI DocAndroid 5.1 API9333Thu Mar 12 22:22:10 GMT 2015android.os.storage

StorageVolume

public class StorageVolume extends Object implements android.os.Parcelable
Description of a storage volume and its capabilities, including the filesystem path where it may be mounted.
hide

Fields Summary
private int
mStorageId
private final File
mPath
private final int
mDescriptionId
private final boolean
mPrimary
private final boolean
mRemovable
private final boolean
mEmulated
private final int
mMtpReserveSpace
private final boolean
mAllowMassStorage
private final long
mMaxFileSize
Maximum file size for the storage, or zero for no limit
private final android.os.UserHandle
mOwner
When set, indicates exclusive ownership of this volume
private String
mUuid
private String
mUserLabel
private String
mState
public static final String
EXTRA_STORAGE_VOLUME
public static final Creator
CREATOR
Constructors Summary
public StorageVolume(File path, int descriptionId, boolean primary, boolean removable, boolean emulated, int mtpReserveSpace, boolean allowMassStorage, long maxFileSize, android.os.UserHandle owner)


            
                   
              
        mPath = path;
        mDescriptionId = descriptionId;
        mPrimary = primary;
        mRemovable = removable;
        mEmulated = emulated;
        mMtpReserveSpace = mtpReserveSpace;
        mAllowMassStorage = allowMassStorage;
        mMaxFileSize = maxFileSize;
        mOwner = owner;
    
private StorageVolume(android.os.Parcel in)

        mStorageId = in.readInt();
        mPath = new File(in.readString());
        mDescriptionId = in.readInt();
        mPrimary = in.readInt() != 0;
        mRemovable = in.readInt() != 0;
        mEmulated = in.readInt() != 0;
        mMtpReserveSpace = in.readInt();
        mAllowMassStorage = in.readInt() != 0;
        mMaxFileSize = in.readLong();
        mOwner = in.readParcelable(null);
        mUuid = in.readString();
        mUserLabel = in.readString();
        mState = in.readString();
    
Methods Summary
public booleanallowMassStorage()
Returns true if this volume can be shared via USB mass storage.

return
whether mass storage is allowed

        return mAllowMassStorage;
    
public intdescribeContents()


    
       
        return 0;
    
public voiddump(com.android.internal.util.IndentingPrintWriter pw)

        pw.println("StorageVolume:");
        pw.increaseIndent();
        pw.printPair("mStorageId", mStorageId);
        pw.printPair("mPath", mPath);
        pw.printPair("mDescriptionId", mDescriptionId);
        pw.printPair("mPrimary", mPrimary);
        pw.printPair("mRemovable", mRemovable);
        pw.printPair("mEmulated", mEmulated);
        pw.printPair("mMtpReserveSpace", mMtpReserveSpace);
        pw.printPair("mAllowMassStorage", mAllowMassStorage);
        pw.printPair("mMaxFileSize", mMaxFileSize);
        pw.printPair("mOwner", mOwner);
        pw.printPair("mUuid", mUuid);
        pw.printPair("mUserLabel", mUserLabel);
        pw.printPair("mState", mState);
        pw.decreaseIndent();
    
public booleanequals(java.lang.Object obj)

        if (obj instanceof StorageVolume && mPath != null) {
            StorageVolume volume = (StorageVolume)obj;
            return (mPath.equals(volume.mPath));
        }
        return false;
    
public static android.os.storage.StorageVolumefromTemplate(android.os.storage.StorageVolume template, java.io.File path, android.os.UserHandle owner)

        return new StorageVolume(path, template.mDescriptionId, template.mPrimary,
                template.mRemovable, template.mEmulated, template.mMtpReserveSpace,
                template.mAllowMassStorage, template.mMaxFileSize, owner);
    
public java.lang.StringgetDescription(android.content.Context context)
Returns a user visible description of the volume.

return
the volume description

        return context.getResources().getString(mDescriptionId);
    
public intgetDescriptionId()

        return mDescriptionId;
    
public intgetFatVolumeId()
Parse and return volume UUID as FAT volume ID, or return -1 if unable to parse or UUID is unknown.

        if (mUuid == null || mUuid.length() != 9) {
            return -1;
        }
        try {
            return (int)Long.parseLong(mUuid.replace("-", ""), 16);
        } catch (NumberFormatException e) {
            return -1;
        }
    
public longgetMaxFileSize()
Returns maximum file size for the volume, or zero if it is unbounded.

return
maximum file size

        return mMaxFileSize;
    
public intgetMtpReserveSpace()
Number of megabytes of space to leave unallocated by MTP. MTP will subtract this value from the free space it reports back to the host via GetStorageInfo, and will not allow new files to be added via MTP if there is less than this amount left free in the storage. If MTP has dedicated storage this value should be zero, but if MTP is sharing storage with the rest of the system, set this to a positive value to ensure that MTP activity does not result in the storage being too close to full.

return
MTP reserve space

        return mMtpReserveSpace;
    
public android.os.UserHandlegetOwner()

        return mOwner;
    
public java.lang.StringgetPath()
Returns the mount path for the volume.

return
the mount path

        return mPath.toString();
    
public java.io.FilegetPathFile()

        return mPath;
    
public java.lang.StringgetState()

        return mState;
    
public intgetStorageId()
Returns the MTP storage ID for the volume. this is also used for the storage_id column in the media provider.

return
MTP storage ID

        return mStorageId;
    
public java.lang.StringgetUserLabel()

        return mUserLabel;
    
public java.lang.StringgetUuid()

        return mUuid;
    
public inthashCode()

        return mPath.hashCode();
    
public booleanisEmulated()
Returns true if the volume is emulated.

return
is removable

        return mEmulated;
    
public booleanisPrimary()

        return mPrimary;
    
public booleanisRemovable()
Returns true if the volume is removable.

return
is removable

        return mRemovable;
    
public voidsetState(java.lang.String state)

        mState = state;
    
public voidsetStorageId(int index)
Do not call this unless you are MountService

        // storage ID is 0x00010001 for primary storage,
        // then 0x00020001, 0x00030001, etc. for secondary storages
        mStorageId = ((index + 1) << 16) + 1;
    
public voidsetUserLabel(java.lang.String userLabel)

        mUserLabel = userLabel;
    
public voidsetUuid(java.lang.String uuid)

        mUuid = uuid;
    
public java.lang.StringtoString()

        final CharArrayWriter writer = new CharArrayWriter();
        dump(new IndentingPrintWriter(writer, "    ", 80));
        return writer.toString();
    
public voidwriteToParcel(android.os.Parcel parcel, int flags)

        parcel.writeInt(mStorageId);
        parcel.writeString(mPath.toString());
        parcel.writeInt(mDescriptionId);
        parcel.writeInt(mPrimary ? 1 : 0);
        parcel.writeInt(mRemovable ? 1 : 0);
        parcel.writeInt(mEmulated ? 1 : 0);
        parcel.writeInt(mMtpReserveSpace);
        parcel.writeInt(mAllowMassStorage ? 1 : 0);
        parcel.writeLong(mMaxFileSize);
        parcel.writeParcelable(mOwner, flags);
        parcel.writeString(mUuid);
        parcel.writeString(mUserLabel);
        parcel.writeString(mState);