package com.bitgrind.android;

import java.util.Arrays;

import jsqlite.Callback;
import jsqlite.Exception;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;

public class SpatialiteTestActivity extends Activity {

  private static final String TAG = SpatialiteTestActivity.class.getSimpleName();

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    jsqlite.Database db = new jsqlite.Database();
    try {

      db.open(Environment.getExternalStorageDirectory() + "/spatialite-test.db",
          jsqlite.Constants.SQLITE_OPEN_CREATE);
      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));

          // Careful (from parent javadoc):
          // "If true is returned the running SQLite query is aborted."
          return false;
        }
      };
      db.exec("SELECT spatialite_version();", cb);
    } catch (Exception e) {
      Log.e(TAG, "Exception caught", e);
    }
  }
}

@@ -101,17 +101,16 @@
 eption;%0A
-%0A
 import a
@@ -341,22 +341,16 @@
 .get
-Simple
 Name();%0A
 %0A  @
@@ -345,17 +345,16 @@
 Name();%0A
-%0A
   @Overr
@@ -487,17 +487,16 @@
 .main);%0A
-%0A
     jsql
@@ -547,17 +547,16 @@
   try %7B%0A
-%0A
       db
@@ -621,9 +621,9 @@
 lite
--
+_
 test
@@ -672,14 +672,16 @@
 PEN_
-C
 REA
-TE
+DONLY
 );%0A 
@@ -1298,28 +1298,99 @@
 ECT 
-spatialite_version()
+name, peoples, AsText(GaiaGeometry) from Towns where peoples %3E 350000 order by peoples DESC
 ;%22, 
@@ -1432,40 +1432,26 @@
     
-Log.e(TAG, %22Exception caught%22, e
+e.printStackTrace(
 );%0A 

Test Activity: Restore the full test with sample db since it causes SIGSEGV :-(