2626
2727import android .content .Context ;
2828import android .content .SharedPreferences ;
29+ import android .content .pm .LabeledIntent ;
2930import android .content .res .AssetManager ;
3031import android .database .Cursor ;
3132import android .database .sqlite .SQLiteDatabase ;
4950import java .net .Socket ;
5051import java .net .SocketException ;
5152import java .util .ArrayList ;
53+ import java .util .Collections ;
5254import java .util .List ;
5355import java .util .Map ;
5456
@@ -372,17 +374,17 @@ private Response query(String sql) {
372374
373375 if (cursor .getCount () > 0 ) {
374376 do {
375- List row = new ArrayList ();
377+ List < Object > row = new ArrayList <> ();
376378 for (int i = 0 ; i < cursor .getColumnCount (); i ++) {
377379 switch (cursor .getType (i )) {
378380 case Cursor .FIELD_TYPE_BLOB :
379381 row .add (cursor .getBlob (i ));
380382 break ;
381383 case Cursor .FIELD_TYPE_FLOAT :
382- row .add (Float . valueOf ( cursor .getFloat (i ) ));
384+ row .add (cursor .getFloat (i ));
383385 break ;
384386 case Cursor .FIELD_TYPE_INTEGER :
385- row .add (Integer . valueOf ( cursor .getInt (i ) ));
387+ row .add (cursor .getInt (i ));
386388 break ;
387389 case Cursor .FIELD_TYPE_STRING :
388390 row .add (cursor .getString (i ));
@@ -395,7 +397,7 @@ private Response query(String sql) {
395397
396398 } while (cursor .moveToNext ());
397399 }
398-
400+ cursor . close ();
399401 return response ;
400402 } else {
401403 Response response = new Response ();
@@ -408,8 +410,9 @@ private Response query(String sql) {
408410 public Response getDBList () {
409411 Response response = new Response ();
410412 if (mDatabaseDir != null ) {
411- for (String name : mDatabaseDir .list ()) {
412- response .rows .add (name );
413+ String [] list = mDatabaseDir .list ();
414+ if (list != null ) {
415+ Collections .addAll (response .rows , list );
413416 }
414417 }
415418 response .rows .add (Constants .APP_SHARED_PREFERENCES );
@@ -427,6 +430,7 @@ public Response getAllTableName() {
427430 c .moveToNext ();
428431 }
429432 }
433+ c .close ();
430434 response .isSuccessful = true ;
431435 return response ;
432436 }
@@ -450,7 +454,7 @@ public Response getAllPrefData(String tag) {
450454 SharedPreferences preferences = mContext .getSharedPreferences (tag , Context .MODE_PRIVATE );
451455 Map <String , ?> allEntries = preferences .getAll ();
452456 for (Map .Entry <String , ?> entry : allEntries .entrySet ()) {
453- List row = new ArrayList ();
457+ List < String > row = new ArrayList <> ();
454458 row .add (entry .getKey ());
455459 row .add (entry .getValue ().toString ());
456460 response .rows .add (row );
0 commit comments