From f1a6ec577f539537ef92a83f8860649e08438a4f Mon Sep 17 00:00:00 2001 From: AMIT SHEKHAR Date: Wed, 23 Nov 2016 14:57:52 +0530 Subject: [PATCH] FIX #10 : null check when database is not present --- .../main/java/com/amitshekhar/server/ClientServer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/debug-db/src/main/java/com/amitshekhar/server/ClientServer.java b/debug-db/src/main/java/com/amitshekhar/server/ClientServer.java index 4c2878f..7e8fe4c 100644 --- a/debug-db/src/main/java/com/amitshekhar/server/ClientServer.java +++ b/debug-db/src/main/java/com/amitshekhar/server/ClientServer.java @@ -29,7 +29,6 @@ import android.content.res.AssetManager; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteException; import android.text.TextUtils; import android.util.Log; @@ -46,7 +45,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; -import java.io.UnsupportedEncodingException; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketException; @@ -409,8 +407,10 @@ private Response query(String sql) { public Response getDBList() { Response response = new Response(); - for (String name : mDatabaseDir.list()) { - response.rows.add(name); + if (mDatabaseDir != null) { + for (String name : mDatabaseDir.list()) { + response.rows.add(name); + } } response.rows.add(Constants.APP_SHARED_PREFERENCES); response.isSuccessful = true;