0、相关文章:
1、正文
2、原因:
3、解决方案:
0、相关文章:
=======
http://www.it1352.com/161373.html
1、正文
====
问题描述:通过一下sql语句,希望根据当前的经纬度查询方圆五公里内的需要打点的所有坐标点的经纬度
String sql = "SELECT * , (6371 * ACOS ( cos ( radians ( " + latitude +
" ) ) * cos( radians(lat) ) * cos( radians(lon) - radians( " + longitude +
" ) ) + sin( radians( " + longitude
"AS distance " +
"FROM " + Constant.TABLE_RDD_IMAGES +
" HAVING distance < 1 " +
"ORDER BY distance " +
“LIMIT 1”;
但是却报错:
2、原因:
=====
SQLite不支持任何默认三角函数,所以你不能在SQL查询中使用它们。
3、解决方案:
=======
https://stackoverflow.com/questions/7867099/how-can-i-create-a-user-defined-function-in-sqlite
SQLite does not have support for user-defined functions in the way that Oracle or MS SQL Server does.
For SQLite, you must create a callback function in C/C++ and hook the function up using the sqlite3_create_function call.
Unfortunately, the SQLite API for Android does not allow for the sqlite3_create_function
call directly through Java. In order to get it to work you will need to compile the SQLite C library with the NDK.
And if you are still interested read 2.3 User-defined functions…
Here’s how to create a function that finds the first byte of a string.
static void firstchar(sqlite3_context *context, int argc, sqlite3_value **argv)
{
if (argc == 1) {
char *text = sqlite3_value_text(argv[0]);
if (text && text[0]) {
char result[2];
result[0] = text[0]; result[1] = ‘\0’;
sqlite3_result_text(context, result, -1, SQLITE_TRANSIENT);
return;
}
}
sqlite3_result_null(context);
由于文章篇幅原因,我只把面试题列了出来,详细的答案,我整理成了一份PDF文档,这份文档还包括了还有 高级架构技术进阶脑图、Android开发面试专题资料,高级进阶架构资料 ,帮助大家学习提升进阶,也节省大家在网上搜索资料的时间来学习。
需要的朋友可以私信我【答案】或者点击这里免费领取