public class Volume extends Object implements Comparable<Volume>
Get the available volumes by calling VolumeManager.getVolumes()
Optionally, volumes can be given a label with a special convention:
A file named .libmedia
, located at the root folder, stores the label (as a UTF-8 string).
Some operations (check, write, delete) are available to manage this file in an application.
Modifier and Type | Field and Description |
---|---|
String |
description
A free field, available for your convenience.
|
static String |
EMULATED_STORAGE
The type returned by
getType() if the volume is emulated from a directory. |
static String |
STORAGE
The type returned by
getType() if the volume is really based on a Storage Provider. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Volume o)
Compares two volumes.
|
boolean |
deleteLabelFile()
Deletes the label file.
|
boolean |
forget()
Releases the authorization once granted by the user to access this volume.
|
String |
getLabel()
Returns the label of the volume.
|
String |
getName()
Returns the name of the volume.
|
DocumentFile |
getRoot()
Returns the root entry of the volume.
|
String |
getType()
Returns the type of storage unit.
|
boolean |
hasLabelFile()
Tells if a label file exists.
|
boolean |
isForgettable()
Tells whether the volume is issued from a previous authorization of the user.
|
String |
toString()
Returns a default string representation of the volume.
|
boolean |
writeLabelFile(String label)
Writes a new label in the label file, creating the file if necessary.
|
public String description
public static final String STORAGE
getType()
if the volume is really based on a Storage Provider.public DocumentFile getRoot()
public String getName()
public String getLabel()
public String getType()
public boolean isForgettable()
true
if the volume can be forgotten.forget()
public boolean hasLabelFile()
true
if the file exists.public boolean writeLabelFile(String label)
label
- The new contents.true
if the operation succeeded.public boolean deleteLabelFile()
true
if the operation succeeded.public boolean forget()
true
if the operation succeeded.isForgettable()
public String toString()
getLabel()
method.public int compareTo(Volume o)
compareTo
in interface Comparable<Volume>
o
- The other volume to be compared to this volume.