private JSONObject executeSqlStatementNDK(String query,JSONArray paramsAsJson,CallbackContext cbc) throws Exception {
  JSONObject rowsResult=new JSONObject();
  boolean hasRows;
  SQLiteStatement myStatement=mydb.prepareStatement(query);
  try {
    for (int i=0; i < paramsAsJson.length(); ++i) {
      if (paramsAsJson.isNull(i)) {
        myStatement.bindNull(i + 1);
      }
 else {
        Object p=paramsAsJson.get(i);
        if (p instanceof Float || p instanceof Double)         myStatement.bindDouble(i + 1,paramsAsJson.getDouble(i));
 else         if (p instanceof Number)         myStatement.bindLong(i + 1,paramsAsJson.getLong(i));
 else         myStatement.bindTextNativeString(i + 1,paramsAsJson.getString(i));
      }
    }
    hasRows=myStatement.step();
  }
 catch (  Exception ex) {
    ex.printStackTrace();
    String errorMessage=ex.getMessage();
    Log.v("executeSqlBatch","SQLitePlugin.executeSql[Batch](): Error=" + errorMessage);
    myStatement.dispose();
    throw ex;
  }
  if (hasRows) {
    JSONArray rowsArrayResult=new JSONArray();
    String key;
    int colCount=myStatement.getColumnCount();
    do {
      JSONObject row=new JSONObject();
      try {
        for (int i=0; i < colCount; ++i) {
          key=myStatement.getColumnName(i);
switch (myStatement.getColumnType(i)) {
case SQLColumnType.NULL:
            row.put(key,JSONObject.NULL);
          break;
case SQLColumnType.REAL:
        row.put(key,myStatement.getColumnDouble(i));
      break;
case SQLColumnType.INTEGER:
    row.put(key,myStatement.getColumnLong(i));
  break;
case SQLColumnType.BLOB:
case SQLColumnType.TEXT:
default :
row.put(key,myStatement.getColumnTextNativeString(i));
}
}
rowsArrayResult.put(row);
}
 catch (JSONException e) {
e.printStackTrace();
}
}
 while (myStatement.step());
try {
rowsResult.put("rows",rowsArrayResult);
}
 catch (JSONException e) {
e.printStackTrace();
}
}
myStatement.dispose();
return rowsResult;
}

private JSONObject executeSqlStatementNDK ( String query , JSONArray paramsAsJson , CallbackContext cbc ) throws Exception { JSONObject rowsResult = new JSONObject ( ) ; boolean hasRows ; SQLiteStatement myStatement = mydb . prepareStatement ( query ) ; try { for ( int i = 0 ; i < paramsAsJson . length ( ) ; ++ i ) { if ( paramsAsJson . isNull ( i ) ) { myStatement . bindNull ( i + 1 ) ; } else { Object p = paramsAsJson . get ( i ) ; if ( p instanceof Float || p instanceof Double ) myStatement . bindDouble ( i + 1 , paramsAsJson . getDouble ( i ) ) ; else if ( p instanceof Number ) myStatement . bindLong ( i + 1 , paramsAsJson . getLong ( i ) ) ; else myStatement . bindTextNativeString ( i + 1 , paramsAsJson . getString ( i ) ) ; } } hasRows = myStatement . step ( ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; String errorMessage = ex . getMessage ( ) ; Log . v ( "executeSqlBatch" , "SQLitePlugin.executeSql[Batch](): Error=" + errorMessage ) ; myStatement . dispose ( ) ; throw ex ; } if ( hasRows ) { JSONArray rowsArrayResult = new JSONArray ( ) ; String key ; int colCount = myStatement . getColumnCount ( ) ; do { JSONObject row = new JSONObject ( ) ; try { for ( int i = 0 ; i < colCount ; ++ i ) { key = myStatement . getColumnName ( i ) ; switch ( myStatement . getColumnType ( i ) ) { case SQLColumnType . NULL : row . put ( key , JSONObject . NULL ) ; break ; case SQLColumnType . REAL : row . put ( key , myStatement . getColumnDouble ( i ) ) ; break ; case SQLColumnType . INTEGER : row . put ( key , myStatement . getColumnLong ( i ) ) ; break ; case SQLColumnType . BLOB : case SQLColumnType . TEXT : default : row . put ( key , myStatement . getColumnTextNativeString ( i ) ) ; } } rowsArrayResult . put ( row ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } } while ( myStatement . step ( ) ) ; try { rowsResult . put ( "rows" , rowsArrayResult ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } } myStatement . dispose ( ) ; return rowsResult ; }
get rows results from query cursor .
