android 端 spatialite 数据库框架
官方网址 https://www.gaia-gis.it/fossil/libspatialite/wiki?name=spatialite-android-tutorial
语法 https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html#p4
问题: 官网 demo 中的so导入不兼容新Android版本, 报错 spatialite has text relocations
https://github.com/MarkTsy/spatialite_for_android/tree/master 解决: 解决了不兼容问题, 可作为module导入AS
实例代码:
jsqlite.Database db = new jsqlite.Database();
try {
db.open((mContext.getFilesDir().getAbsolutePath() + File.separator + DB_NAME), jsqlite.Constants.SQLITE_OPEN_READONLY);
Callback cb = new Callback() {
@Override
public void columns(String[] coldata) {
Log.v(TAG, "Columns: " + Arrays.toString(coldata));
}
@Override
public void types(String[] types) {
Log.v(TAG, "Types: " + Arrays.toString(types));
}
@Override
public boolean newrow(String[] rowdata) {
Log.v(TAG, "Row: " + Arrays.toString(rowdata));
return false;
}
};
String query = "SELECT AsText(GEOMETRY) from Table";
db.exec(query, cb);
db.close();
} catch (Exception e) {
e.printStackTrace();
}
|