Package com.android.sdklib.devices
Class Storage
- java.lang.Object
-
- com.android.sdklib.devices.Storage
-
public class Storage extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStorage.Unit
-
Constructor Summary
Constructors Constructor Description Storage(long amount)Storage(long amount, Storage.Unit unit)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StoragedeepCopy()booleanequals(java.lang.Object other)Storage.UnitgetAppropriateUnits()Finds the largestStorage.Unitwhich can display the storage value as a positive integer with no loss of accuracy.Storage.UnitgetLargestReasonableUnits()Finds the largestStorage.Unitwhich can display the storage value with non-zero integer part.doublegetPreciseSizeAsUnit(Storage.Unit unit)Returns the amount of storage represented by the instance in the given unit as a double to get a more precise resultlonggetSize()Returns the amount of storage represented, in ByteslonggetSizeAsUnit(Storage.Unit unit)Return the amount of storage represented by the instance in the given unitstatic StoragegetStorageFromString(java.lang.String storageString)Decodes the given string and returns aStorageof the corresponding size.inthashCode()booleanlessThan(java.lang.Object other)java.lang.StringtoIniString()Represents aStorageas a string suitable for use in an INI file.java.lang.StringtoString()java.lang.StringtoUiString()Represents aStorageas a string suitable for displaying in the UI.java.lang.StringtoUiString(int precision)Represents aStorageas a string suitable for displaying in the UI.
-
-
-
Constructor Detail
-
Storage
public Storage(long amount, Storage.Unit unit)
-
Storage
public Storage(long amount)
-
-
Method Detail
-
getSize
public long getSize()
Returns the amount of storage represented, in Bytes
-
deepCopy
@NonNull public Storage deepCopy()
-
getSizeAsUnit
public long getSizeAsUnit(@NonNull Storage.Unit unit)Return the amount of storage represented by the instance in the given unit- Parameters:
unit- The unit of the result.- Returns:
- The size of the storage in the given unit.
-
getPreciseSizeAsUnit
public double getPreciseSizeAsUnit(@NonNull Storage.Unit unit)Returns the amount of storage represented by the instance in the given unit as a double to get a more precise result- Parameters:
unit- The unit of the result.- Returns:
- The size of the storage in the given unit.
-
getStorageFromString
@Nullable public static Storage getStorageFromString(@Nullable java.lang.String storageString)
Decodes the given string and returns aStorageof the corresponding size. The input string can look like these: "2" "2B" "2MB" "2 M" "2 MB" But NOT like these: "2m" "2.6" "2 MiB"
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
lessThan
public boolean lessThan(java.lang.Object other)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getAppropriateUnits
@NonNull public Storage.Unit getAppropriateUnits()
Finds the largestStorage.Unitwhich can display the storage value as a positive integer with no loss of accuracy.- Returns:
- The most appropriate
Storage.Unit.
-
getLargestReasonableUnits
@NonNull public Storage.Unit getLargestReasonableUnits()
Finds the largestStorage.Unitwhich can display the storage value with non-zero integer part. This might be useful for displaying in user interface where full precision is not critical and can be sacrificed in favor of better UX.- Returns:
- The largest
Storage.Unitsuch that getSize()/Unit.getNumberOfBytes() is not zero.
-
toString
@NonNull public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toUiString
public java.lang.String toUiString()
Represents aStorageas a string suitable for displaying in the UI.
-
toUiString
public java.lang.String toUiString(int precision)
Represents aStorageas a string suitable for displaying in the UI.- Parameters:
precision- The number of digits after decimal point to display.
-
toIniString
@NonNull public java.lang.String toIniString()
Represents aStorageas a string suitable for use in an INI file.
-
-