SQLite Database Custom Function implementation:
//Here's how to create a function, that finds the first character of a string.Static voidFirstchar (Sqlite3_context *context,intARGC, Sqlite3_value * *argv) { if(ARGC = =1) { Char*text = Sqlite3_value_text (argv[0]); if(Text && text[0]) { Charresult[2]; result[0] = text[0]; result[1] =' /'; Sqlite3_result_text (context, result,-1, sqlite_transient); return; }} sqlite3_result_null (context);}//Then attach the function to the database.sqlite3_create_function (DB,"Firstchar",1, Sqlite_utf8, NULL, &firstchar, NULL, NULL);//Finally, use the function in a SQL statement.//SELECT Firstchar (TextField) from table
Remark: AHR0CCUZQS8VD3D3LMNUYMXVZ3MUY29TL3POAGQV
Reference code: Aosp/external/sqlite/android/sqlite3_android.cpp
Reference Link: http://stackoverflow.com/questions/7867099/how-can-i-create-a-user-defined-function-in-sqlite
Reference Link: http://www.cnblogs.com/imouto/archive/2013/06/14/how-to-add-user-defined-functions-for-sqlite.html
Android SQLite joins custom functions