Skip to content

Commit

Permalink
FIX #10 : null check when database is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
amitshekhariitbhu committed Nov 23, 2016
1 parent 1bf388d commit f1a6ec5
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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()) {

This comment has been minimized.

Copy link
@codebymikey

codebymikey Nov 23, 2016

Contributor

The bug is that mDatabaseDir.list() returns null. Causing the for loop to fail and throw a NullPointerException.

response.rows.add(name);
}
}
response.rows.add(Constants.APP_SHARED_PREFERENCES);
response.isSuccessful = true;
Expand Down

0 comments on commit f1a6ec5

Please sign in to comment.