FileDocCategorySizeDatePackage
MtpStorage.javaAPI DocAndroid 5.1 API3177Thu Mar 12 22:22:30 GMT 2015android.mtp

MtpStorage

public class MtpStorage extends Object
This class represents a storage unit on an MTP device. Used only for MTP support in USB responder mode. MtpStorageInfo is used in MTP host mode
hide

Fields Summary
private final int
mStorageId
private final String
mPath
private final String
mDescription
private final long
mReserveSpace
private final boolean
mRemovable
private final long
mMaxFileSize
Constructors Summary
public MtpStorage(android.os.storage.StorageVolume volume, android.content.Context context)

        mStorageId = volume.getStorageId();
        mPath = volume.getPath();
        mDescription = context.getResources().getString(volume.getDescriptionId());
        mReserveSpace = volume.getMtpReserveSpace() * 1024L * 1024L;
        mRemovable = volume.isRemovable();
        mMaxFileSize = volume.getMaxFileSize();
    
Methods Summary
public final java.lang.StringgetDescription()
Returns the description string for the storage unit

return
the storage unit description

        return mDescription;
    
public longgetMaxFileSize()
Returns maximum file size for the storage, or zero if it is unbounded.

return
maximum file size

        return mMaxFileSize;
    
public final java.lang.StringgetPath()
Returns the file path for the storage unit's storage in the file system

return
the storage file path

        return mPath;
    
public final longgetReserveSpace()
Returns the amount of space to reserve on the storage file system. This can be set to a non-zero value to prevent MTP from filling up the entire storage.

return
reserved space in bytes.

        return mReserveSpace;
    
public final intgetStorageId()
Returns the storage ID for the storage unit

return
the storage ID

        return mStorageId;
    
public static intgetStorageId(int index)
Generates a storage ID for storage of given index. Index 0 is for primary external storage

return
the storage ID

        // storage ID is 0x00010001 for primary storage,
        // then 0x00020001, 0x00030001, etc. for secondary storages
        return ((index + 1) << 16) + 1;
    
public final booleanisRemovable()
Returns true if the storage is removable.

return
is removable

        return mRemovable;