From 9373a5fd3ff15b55417ad3a8af97b8374a39598e Mon Sep 17 00:00:00 2001 From: Martin Carpella Date: Thu, 20 Oct 2016 20:48:36 +0200 Subject: [PATCH] Fix NullPointerException for STGUIASSETS On devices without SD-card / shared-storage, getExternalFilesDir() may return null. --- .../syncthingandroid/syncthing/SyncthingRunnable.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingRunnable.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingRunnable.java index fa6ef8e1..edd19edd 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingRunnable.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingRunnable.java @@ -13,6 +13,7 @@ import com.nutomic.syncthingandroid.BuildConfig; import java.io.BufferedReader; import java.io.DataOutputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -118,7 +119,9 @@ public class SyncthingRunnable implements Runnable { // Set home directory to data folder for web GUI folder picker. env.put("HOME", Environment.getExternalStorageDirectory().getAbsolutePath()); env.put("STTRACE", sp.getString("sttrace", "")); - env.put("STGUIASSETS", mContext.getExternalFilesDir(null).getAbsolutePath() + "/gui"); + File externalFilesDir = mContext.getExternalFilesDir(null); + if (externalFilesDir != null) + env.put("STGUIASSETS", externalFilesDir.getAbsolutePath() + "/gui"); env.put("STNORESTART", "1"); env.put("STNOUPGRADE", "1"); if (sp.getBoolean("use_tor", false)) {