I'm using the Android SQLite Binding and the addCustomFunction method is unhidden. I can see how the arguments are passed in but once they've been processed I don't know how to pass it back as a result.
public class Custom implements SQLiteDatabase.CustomFunction {
@Override
public void callback(String[] args) {
String.valueOf(Math.cos(Double.parseDouble(args[0])));
}
}
I'm trying to make a cos function but it returns null every time I call the function. It's basically because I don't know where to pass the result.
db.execSQL("CREATE TABLE t1(x)");
db.execSQL("INSERT INTO t1 VALUES ('one'), ('two'), ('three')");
Custom custom = new Custom();
db.addCustomFunction("cos",1,custom);
try {
Cursor c = db.rawQuery("SELECT cos(0.5),* FROM t1", null);
if (c != null && c.moveToFirst()) {
res += c.getString(0);
Toast.makeText(this, res, Toast.LENGTH_LONG).show();
}
}
catch (Exception e){
Log.e("EXP","custom",e);
}