Module com.gluonhq.attach.storage
Package com.gluonhq.attach.storage.impl
Class AndroidStorageService
- java.lang.Object
-
- com.gluonhq.attach.storage.impl.AndroidStorageService
-
- All Implemented Interfaces:
StorageService
public class AndroidStorageService extends java.lang.Object implements StorageService
-
-
Constructor Summary
Constructors Constructor Description AndroidStorageService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.booleanisExternalStorageReadable()Checks if external storage is available for read access.booleanisExternalStorageWritable()Checks if external storage is available for read and write access.
-
-
-
Method Detail
-
getPrivateStorage
public java.util.Optional<java.io.File> getPrivateStorage()
Description copied from interface:StorageServiceGet a storage directory that is private to the environment that is calling this method. In the case of iOS or Android, the returned directory is private to the enclosing application.- Specified by:
getPrivateStoragein interfaceStorageService- Returns:
- an optional with a private storage directory for an application
-
getPublicStorage
public java.util.Optional<java.io.File> getPublicStorage(java.lang.String subdirectory)
Description copied from interface:StorageServiceGet a public storage directory location.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
StorageService.isExternalStorageWritable()orStorageService.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.
- Specified by:
getPublicStoragein interfaceStorageService- Parameters:
subdirectory- under the root of public storage that is required. On Android the supplied subdirectory should not be null.- Returns:
- an Optional of a File representing the requested directory location. The location may not yet exist. It is the responsibility of the programmer to ensure that the location exists before using it.
-
isExternalStorageWritable
public boolean isExternalStorageWritable()
Description copied from interface:StorageServiceChecks if external storage is available for read and write access.- Specified by:
isExternalStorageWritablein interfaceStorageService- Returns:
- true if the externalStorage is writable (implies readable), false otherwise
-
isExternalStorageReadable
public boolean isExternalStorageReadable()
Description copied from interface:StorageServiceChecks if external storage is available for read access.- Specified by:
isExternalStorageReadablein interfaceStorageService- Returns:
- true if the externalStorage is at least readable, false otherwise
-
-