private JSONObject executeSqlStatementQuery(SQLiteDatabase mydb,String query,JSONArray paramsAsJson,CallbackContext cbc) throws Exception {
  JSONObject rowsResult=new JSONObject();
  Cursor cur=null;
  try {
    String[] params=null;
    params=new String[paramsAsJson.length()];
    for (int j=0; j < paramsAsJson.length(); j++) {
      if (paramsAsJson.isNull(j))       params[j]="";
 else       params[j]=paramsAsJson.getString(j);
    }
    cur=mydb.rawQuery(query,params);
  }
 catch (  Exception ex) {
    ex.printStackTrace();
    String errorMessage=ex.getMessage();
    Log.v("executeSqlBatch","SQLiteAndroidDatabase.executeSql[Batch](): Error=" + errorMessage);
    throw ex;
  }
  if (cur != null && cur.moveToFirst()) {
    JSONArray rowsArrayResult=new JSONArray();
    String key="";
    int colCount=cur.getColumnCount();
    do {
      JSONObject row=new JSONObject();
      try {
        for (int i=0; i < colCount; ++i) {
          key=cur.getColumnName(i);
          if (android.os.Build.VERSION.SDK_INT >= 11) {
            try {
              bindPostHoneycomb(row,key,cur,i);
            }
 catch (            Exception ex) {
              bindPreHoneycomb(row,key,cur,i);
            }
          }
 else {
            bindPreHoneycomb(row,key,cur,i);
          }
        }
        rowsArrayResult.put(row);
      }
 catch (      JSONException e) {
        e.printStackTrace();
      }
    }
 while (cur.moveToNext());
    try {
      rowsResult.put("rows",rowsArrayResult);
    }
 catch (    JSONException e) {
      e.printStackTrace();
    }
  }
  if (cur != null) {
    cur.close();
  }
  return rowsResult;
}

private JSONObject executeSqlStatementQuery ( SQLiteDatabase mydb , String query , JSONArray paramsAsJson , CallbackContext cbc ) throws Exception { JSONObject rowsResult = new JSONObject ( ) ; Cursor cur = null ; try { String [ ] params = null ; params = new String [ paramsAsJson . length ( ) ] ; for ( int j = 0 ; j < paramsAsJson . length ( ) ; j ++ ) { if ( paramsAsJson . isNull ( j ) ) params [ j ] = "" ; else params [ j ] = paramsAsJson . getString ( j ) ; } cur = mydb . rawQuery ( query , params ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; String errorMessage = ex . getMessage ( ) ; Log . v ( "executeSqlBatch" , "SQLiteAndroidDatabase.executeSql[Batch](): Error=" + errorMessage ) ; throw ex ; } if ( cur != null && cur . moveToFirst ( ) ) { JSONArray rowsArrayResult = new JSONArray ( ) ; String key = "" ; int colCount = cur . getColumnCount ( ) ; do { JSONObject row = new JSONObject ( ) ; try { for ( int i = 0 ; i < colCount ; ++ i ) { key = cur . getColumnName ( i ) ; if ( android . os . Build . VERSION . SDK_INT >= 11 ) { try { bindPostHoneycomb ( row , key , cur , i ) ; } catch ( Exception ex ) { bindPreHoneycomb ( row , key , cur , i ) ; } } else { bindPreHoneycomb ( row , key , cur , i ) ; } } rowsArrayResult . put ( row ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } } while ( cur . moveToNext ( ) ) ; try { rowsResult . put ( "rows" , rowsArrayResult ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } } if ( cur != null ) { cur . close ( ) ; } return rowsResult ; }
get rows results from query cursor .
