Check if Environment.getExternalStorageDirectory() is MOUNTED.
This commit is contained in:
parent
8b48328c4b
commit
2939a5e8dc
1 changed files with 10 additions and 0 deletions
|
|
@ -485,6 +485,16 @@ class BookRepositoryImpl @Inject constructor(
|
|||
.map { bookMapper.toBook(it) }
|
||||
|
||||
val primaryDirectory = Environment.getExternalStorageDirectory()
|
||||
|
||||
if (
|
||||
!primaryDirectory.exists() ||
|
||||
(Environment.getExternalStorageState() != Environment.MEDIA_MOUNTED &&
|
||||
Environment.getExternalStorageState() != Environment.MEDIA_MOUNTED_READ_ONLY)
|
||||
) {
|
||||
emit(Resource.Success(null))
|
||||
return@flow
|
||||
}
|
||||
|
||||
val allFiles = getAllFilesInDirectory(primaryDirectory)
|
||||
|
||||
if (allFiles.isEmpty()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue