# FileStore

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Protected Ctors](https://developer.android.com/reference/java/nio/file/FileStore#proctors)\|[Methods](https://developer.android.com/reference/java/nio/file/FileStore#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/nio/file/FileStore#inhmethods)  

# FileStore

`
public


abstract
class
FileStore
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.nio.file.FileStore |

<br />

*** ** * ** ***

Storage for files. A`FileStore`represents a storage pool, device, partition, volume, concrete file system or other implementation specific means of file storage. The`FileStore`for where a file is stored is obtained by invoking the[getFileStore](https://developer.android.com/reference/java/nio/file/Files#getFileStore(java.nio.file.Path))method, or all file stores can be enumerated by invoking the[getFileStores](https://developer.android.com/reference/java/nio/file/FileSystem#getFileStores())method.

In addition to the methods defined by this class, a file store may support one or more[FileStoreAttributeView](https://developer.android.com/reference/java/nio/file/attribute/FileStoreAttributeView)classes that provide a read-only or updatable view of a set of file store attributes.

## Summary

|                                                          ### Protected constructors                                                           ||
|--------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[FileStore](https://developer.android.com/reference/java/nio/file/FileStore#FileStore())`() ` Initializes a new instance of this class. |

|                                                                                                                                                                                                                                                                                                                        ### Public methods                                                                                                                                                                                                                                                                                                                        ||
|----------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract `[Object](https://developer.android.com/reference/java/lang/Object)                                                               | ` `[getAttribute](https://developer.android.com/reference/java/nio/file/FileStore#getAttribute(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` attribute) ` Reads the value of a file store attribute.                                                                                                                                                                                                                                                                    |
| ` long`                                                                                                                                      | ` `[getBlockSize](https://developer.android.com/reference/java/nio/file/FileStore#getBlockSize())`() ` Returns the number of bytes per block in this file store.                                                                                                                                                                                                                                                                                                                                                   |
| ` abstract <V extends `[FileStoreAttributeView](https://developer.android.com/reference/java/nio/file/attribute/FileStoreAttributeView)`> V` | ` `[getFileStoreAttributeView](https://developer.android.com/reference/java/nio/file/FileStore#getFileStoreAttributeView(java.lang.Class<V>))`(`[Class](https://developer.android.com/reference/java/lang/Class)`<V> type) ` Returns a`FileStoreAttributeView`of the given type.                                                                                                                                                                                                                                   |
| ` abstract long`                                                                                                                             | ` `[getTotalSpace](https://developer.android.com/reference/java/nio/file/FileStore#getTotalSpace())`() ` Returns the size, in bytes, of the file store.                                                                                                                                                                                                                                                                                                                                                            |
| ` abstract long`                                                                                                                             | ` `[getUnallocatedSpace](https://developer.android.com/reference/java/nio/file/FileStore#getUnallocatedSpace())`() ` Returns the number of unallocated bytes in the file store.                                                                                                                                                                                                                                                                                                                                    |
| ` abstract long`                                                                                                                             | ` `[getUsableSpace](https://developer.android.com/reference/java/nio/file/FileStore#getUsableSpace())`() ` Returns the number of bytes available to this Java virtual machine on the file store.                                                                                                                                                                                                                                                                                                                   |
| ` abstract boolean`                                                                                                                          | ` `[isReadOnly](https://developer.android.com/reference/java/nio/file/FileStore#isReadOnly())`() ` Tells whether this file store is read-only.                                                                                                                                                                                                                                                                                                                                                                     |
| ` abstract `[String](https://developer.android.com/reference/java/lang/String)                                                               | ` `[name](https://developer.android.com/reference/java/nio/file/FileStore#name())`() ` Returns the name of this file store.                                                                                                                                                                                                                                                                                                                                                                                        |
| ` abstract boolean`                                                                                                                          | ` `[supportsFileAttributeView](https://developer.android.com/reference/java/nio/file/FileStore#supportsFileAttributeView(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Tells whether or not this file store supports the file attributes identified by the given file attribute view.                                                                                                                                                                           |
| ` abstract boolean`                                                                                                                          | ` `[supportsFileAttributeView](https://developer.android.com/reference/java/nio/file/FileStore#supportsFileAttributeView(java.lang.Class<?%20extends%20java.nio.file.attribute.FileAttributeView>))`(`[Class](https://developer.android.com/reference/java/lang/Class)`<? extends `[FileAttributeView](https://developer.android.com/reference/java/nio/file/attribute/FileAttributeView)`> type) ` Tells whether or not this file store supports the file attributes identified by the given file attribute view. |
| ` abstract `[String](https://developer.android.com/reference/java/lang/String)                                                               | ` `[type](https://developer.android.com/reference/java/nio/file/FileStore#type())`() ` Returns the*type*of this file store.                                                                                                                                                                                                                                                                                                                                                                                        |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Protected constructors

### FileStore

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected FileStore ()
```

Initializes a new instance of this class.

<br />

## Public methods

### getAttribute

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Object getAttribute (String attribute)
```

Reads the value of a file store attribute.

The`attribute`parameter identifies the attribute to be read and takes the form:
> *view-name* **:** *attribute-name*
where the character`':'`stands for itself.

*view-name* is the[name](https://developer.android.com/reference/java/nio/file/attribute/AttributeView#name())of a[AttributeView](https://developer.android.com/reference/java/nio/file/FileStore)that identifies a set of file attributes.*attribute-name*is the name of the attribute.

**Usage Example:**Suppose we want to know if ZFS compression is enabled (assuming the "zfs" view is supported):  

```
    boolean compression = (Boolean)fs.getAttribute("zfs:compression");
 
```

<br />

<br />

|                     Parameters                      ||
|-------------|----------------------------------------|
| `attribute` | `String`: the attribute to read <br /> |

|                                                                Returns                                                                ||
|--------------------------------------------------------------------|-------------------------------------------------------------------|
| [Object](https://developer.android.com/reference/java/lang/Object) | the attribute value;`null`may be valid for some attributes <br /> |

|                                                                                                Throws                                                                                                 ||
|------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
| [UnsupportedOperationException](https://developer.android.com/reference/java/lang/UnsupportedOperationException) | if the attribute view is not available or it does not support reading the attribute |
| [IOException](https://developer.android.com/reference/java/io/IOException)                                       | if an I/O error occurs                                                              |

### getBlockSize

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long getBlockSize ()
```

Returns the number of bytes per block in this file store.

File storage is typically organized into discrete sequences of bytes called*blocks*. A block is the smallest storage unit of a file store. Every read and write operation is performed on a multiple of blocks.

<br />

##### Implementation Requirements:

- The implementation in this class throws an`UnsupportedOperationException`.

|                                         Returns                                          ||
|--------|----------------------------------------------------------------------------------|
| `long` | a positive value representing the block size of this file store, in bytes <br /> |

|                                                                       Throws                                                                        ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException)                                       | if an I/O error occurs            |
| [UnsupportedOperationException](https://developer.android.com/reference/java/lang/UnsupportedOperationException) | if the operation is not supported |

### getFileStoreAttributeView

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract V getFileStoreAttributeView (Class<V> type)
```

Returns a`FileStoreAttributeView`of the given type.

This method is intended to be used where the file store attribute view defines type-safe methods to read or update the file store attributes. The`type`parameter is the type of the attribute view required and the method returns an instance of that type if supported.

<br />

|                                  Parameters                                  ||
|--------|----------------------------------------------------------------------|
| `type` | `Class`: the`Class`object corresponding to the attribute view <br /> |

|                                                   Returns                                                    ||
|-----|---------------------------------------------------------------------------------------------------------|
| `V` | a file store attribute view of the specified type or`null`if the attribute view is not available <br /> |

### getTotalSpace

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract long getTotalSpace ()
```

Returns the size, in bytes, of the file store.

<br />

|                       Returns                       ||
|--------|---------------------------------------------|
| `long` | the size of the file store, in bytes <br /> |

|                                               Throws                                               ||
|----------------------------------------------------------------------------|------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | if an I/O error occurs |

### getUnallocatedSpace

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract long getUnallocatedSpace ()
```

Returns the number of unallocated bytes in the file store.

The returned number of unallocated bytes is a hint, but not a guarantee, that it is possible to use most or any of these bytes. The number of unallocated bytes is most likely to be accurate immediately after the space attributes are obtained. It is likely to be made inaccurate by any external I/O operations including those made on the system outside of this virtual machine.

<br />

|                    Returns                     ||
|--------|----------------------------------------|
| `long` | the number of unallocated bytes <br /> |

|                                               Throws                                               ||
|----------------------------------------------------------------------------|------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | if an I/O error occurs |

### getUsableSpace

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract long getUsableSpace ()
```

Returns the number of bytes available to this Java virtual machine on the file store.

The returned number of available bytes is a hint, but not a guarantee, that it is possible to use most or any of these bytes. The number of usable bytes is most likely to be accurate immediately after the space attributes are obtained. It is likely to be made inaccurate by any external I/O operations including those made on the system outside of this Java virtual machine.

<br />

|                   Returns                    ||
|--------|--------------------------------------|
| `long` | the number of bytes available <br /> |

|                                               Throws                                               ||
|----------------------------------------------------------------------------|------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | if an I/O error occurs |

### isReadOnly

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean isReadOnly ()
```

Tells whether this file store is read-only. A file store is read-only if it does not support write operations or other changes to files. Any attempt to create a file, open an existing file for writing etc. causes an`IOException`to be thrown.

<br />

|                                Returns                                ||
|-----------|------------------------------------------------------------|
| `boolean` | `true`if, and only if, this file store is read-only <br /> |

### name

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract String name ()
```

Returns the name of this file store. The format of the name is highly implementation specific. It will typically be the name of the storage pool or volume.

The string returned by this method may differ from the string returned by the[toString](https://developer.android.com/reference/java/lang/Object#toString())method.

<br />

|                                                Returns                                                 ||
|--------------------------------------------------------------------|------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | the name of this file store <br /> |

### supportsFileAttributeView

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean supportsFileAttributeView (String name)
```

Tells whether or not this file store supports the file attributes identified by the given file attribute view.

Invoking this method to test if the file store supports[BasicFileAttributeView](https://developer.android.com/reference/java/nio/file/attribute/BasicFileAttributeView), identified by the name "`basic`" will always return`true`. In the case of the default provider, this method cannot guarantee to give the correct result when the file store is not a local storage device. The reasons for this are implementation specific and therefore unspecified.

<br />

|                                                                   Parameters                                                                   ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------|
| `name` | `String`: the[name](https://developer.android.com/reference/java/nio/file/attribute/AttributeView#name())of file attribute view <br /> |

|                                    Returns                                    ||
|-----------|--------------------------------------------------------------------|
| `boolean` | `true`if, and only if, the file attribute view is supported <br /> |

### supportsFileAttributeView

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean supportsFileAttributeView (Class<? extends FileAttributeView> type)
```

Tells whether or not this file store supports the file attributes identified by the given file attribute view.

Invoking this method to test if the file store supports[BasicFileAttributeView](https://developer.android.com/reference/java/nio/file/attribute/BasicFileAttributeView)will always return`true`. In the case of the default provider, this method cannot guarantee to give the correct result when the file store is not a local storage device. The reasons for this are implementation specific and therefore unspecified.

<br />

|                      Parameters                      ||
|--------|----------------------------------------------|
| `type` | `Class`: the file attribute view type <br /> |

|                                    Returns                                    ||
|-----------|--------------------------------------------------------------------|
| `boolean` | `true`if, and only if, the file attribute view is supported <br /> |

### type

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract String type ()
```

Returns the*type*of this file store. The format of the string returned by this method is highly implementation specific. It may indicate, for example, the format used or if the file store is local or remote.

<br />

|                                                           Returns                                                            ||
|--------------------------------------------------------------------|----------------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | a string representing the type of this file store <br /> |