@@ -201,25 +201,38 @@ private String getAllDataFromTheTableResponse(String route) {
201201
202202 private String executeQueryAndGetResponse (String route ) {
203203 String query = null ;
204- if (route .contains ("?query=" )) {
205- query = route .substring (route .indexOf ("=" ) + 1 , route .length ());
206- }
204+ String data = null ;
205+ String first ;
207206 try {
208- query = java .net .URLDecoder .decode (query , "UTF-8" );
207+ if (route .contains ("?query=" )) {
208+ query = route .substring (route .indexOf ("=" ) + 1 , route .length ());
209+ }
210+ try {
211+ query = URLDecoder .decode (query , "UTF-8" );
212+ } catch (Exception e ) {
213+ e .printStackTrace ();
214+ }
215+
216+ if (query != null ) {
217+ first = query .split (" " )[0 ].toLowerCase ();
218+ if (first .equals ("select" )) {
219+ TableDataResponse response = DatabaseHelper .query (mDatabase , query );
220+ data = mGson .toJson (response );
221+ } else {
222+ Response response = DatabaseHelper .exec (mDatabase , query );
223+ data = mGson .toJson (response );
224+ }
225+ }
209226 } catch (Exception e ) {
210227 e .printStackTrace ();
211228 }
212229
213- String first = query .split (" " )[0 ].toLowerCase ();
214-
215- String data ;
216- if (first .equals ("select" )) {
217- TableDataResponse response = DatabaseHelper .query (mDatabase , query );
218- data = mGson .toJson (response );
219- } else {
220- Response response = DatabaseHelper .exec (mDatabase , query );
230+ if (data == null ) {
231+ Response response = new Response ();
232+ response .isSuccessful = false ;
221233 data = mGson .toJson (response );
222234 }
235+
223236 return data ;
224237 }
225238
0 commit comments