public interface StorageService
Example
File privateStorage = Services.get(StorageService.class)
.flatMap(StorageService::getPrivateStorage)
.orElseThrow(() -> new FileNotFoundException("Could not access private storage."));
);}
Android Configuration
The permissions android.permission.READ_EXTERNAL_STORAGE
and
android.permission.WRITE_EXTERNAL_STORAGE
are required if you want to access the external
storage on the device for read and/or write operations respectively. Defining write permissions implicitly
activate read permissions as well.
<manifest ...>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
...
<activity android:name="com.gluonhq.impl.charm.down.plugins.android.PermissionRequestActivity" />
</manifest>
iOS Configuration: none
Modifier and Type | Method and Description |
---|---|
java.util.Optional<java.io.File> |
getPrivateStorage()
Get a storage directory that is private to the environment that is
calling this method.
|
java.util.Optional<java.io.File> |
getPublicStorage(java.lang.String subdirectory)
Get a public storage directory location.
|
boolean |
isExternalStorageReadable()
Checks if external storage is available for read access.
|
boolean |
isExternalStorageWritable()
Checks if external storage is available for read and write access.
|
java.util.Optional<java.io.File> getPrivateStorage()
java.util.Optional<java.io.File> getPublicStorage(java.lang.String subdirectory)
Note that on Android the public location could be mapped to a removable memory device and may
not always be available. Users of this method are advised to call isExternalStorageWritable()
or isExternalStorageReadable()
to avoid surprises.
Note also that on Android, permissions will need to be set to access external storage. See: https://developer.android.com/training/basics/data-storage/files.html.
subdirectory
- under the root of public storage that is required. On Android the supplied subdirectory should not be null.boolean isExternalStorageWritable()
boolean isExternalStorageReadable()