1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-09 03:31:46 +00:00

Fix crash after sdcard was ejected (fixes #249) (#250)

This commit is contained in:
Catfriend1 2019-01-20 11:42:01 +00:00 committed by GitHub
parent 18edb74a58
commit beee401baa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 0 deletions

View file

@ -108,6 +108,7 @@ public class FolderPickerActivity extends SyncthingActivity
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
roots.addAll(Arrays.asList(getExternalFilesDirs(null)));
roots.remove(getExternalFilesDir(null));
roots.remove(null); // getExternalFilesDirs may return null for an ejected SDcard.
}
String rootDir = getIntent().getStringExtra(EXTRA_ROOT_DIRECTORY);

View file

@ -48,6 +48,7 @@ public class TipsAndTricksActivity extends SyncthingActivity {
ArrayList<File> externalFilesDir = new ArrayList<>();
externalFilesDir.addAll(Arrays.asList(getExternalFilesDirs(null)));
externalFilesDir.remove(getExternalFilesDir(null));
externalFilesDir.remove(null); // getExternalFilesDirs may return null for an ejected SDcard.
if (externalFilesDir.size() > 0) {
String absExternalStorageAppFilesPath = externalFilesDir.get(0).getAbsolutePath();
mTipListAdapter.add(getString(R.string.tip_write_to_sdcard_title),

View file

@ -167,6 +167,7 @@ public class FileUtils {
ArrayList<File> externalFilesDir = new ArrayList<>();
externalFilesDir.addAll(Arrays.asList(context.getExternalFilesDirs(null)));
externalFilesDir.remove(context.getExternalFilesDir(null));
externalFilesDir.remove(null); // getExternalFilesDirs may return null for an ejected SDcard.
if (externalFilesDir.size() == 0) {
Log.w(TAG, "Could not determine app's private files directory on external storage.");
return null;