package com.bitgrind.android;

import java.io.IOException;
import java.util.Arrays;

import com.bitgrind.android.R;

import SQLite.Callback;
import SQLite.Exception;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class SpatialiteTestActivity extends Activity {

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

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
		SQLite.Database db = new SQLite.Database();
		try {
			db.open("/mnt/sdcard/spatialite_test.db", SQLite.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));
					
					// Careful (from parent javadoc):
					// "If true is returned the running SQLite query is aborted."
					return false;
				}};
				db.exec("SELECT load_extension('libspatialite.so');", cb);
			db.exec("SELECT name, peoples, AsText(GaiaGeometry) from Towns where peoples > 350000 order by peoples DESC;", cb);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

@@ -40,79 +40,19 @@
 ava.
-io.IOException;%0Aimport java.util.Arrays;%0A%0Aimport com.bitgrind.android.R
+util.Arrays
 ;%0A%0Ai
@@ -154,16 +154,47 @@
 Bundle;%0A
+import android.os.Environment;%0A
 import a
@@ -267,17 +267,18 @@
 vity %7B%0A%0A
-%09
+  
 private 
@@ -335,16 +335,22 @@
 lass.get
+Simple
 Name();%0A
@@ -350,17 +350,18 @@
 ame();%0A%0A
-%09
+  
 @Overrid
@@ -362,17 +362,18 @@
 verride%0A
-%09
+  
 protecte
@@ -417,18 +417,20 @@
 tate) %7B%0A
-%09%09
+    
 super.on
@@ -457,18 +457,20 @@
 State);%0A
-%09%09
+    
 setConte
@@ -492,21 +492,21 @@
 .main);%0A
-%09%09%0A%09%09
+%0A    
 SQLite.D
@@ -545,27 +545,33 @@
 ();%0A
-%09%09
+    
 try %7B%0A
-%09%09%09
+%0A      
 db.open(
 %22/mn
@@ -570,20 +570,53 @@
 pen(
-%22/mnt/sdcard
+Environment.getExternalStorageDirectory() + %22
 /spa
@@ -622,17 +622,17 @@
 atialite
-_
+-
 test.db%22
@@ -632,16 +632,26 @@
 est.db%22,
+%0A         
  SQLite.
@@ -676,22 +676,23 @@
 PEN_
+C
 REA
-DONLY);%0A%09%09%09
+TE);%0A      
 Call
@@ -718,20 +718,24 @@
 ack() %7B%0A
-%09%09%09%09
+        
 @Overrid
@@ -728,36 +728,40 @@
       @Override%0A
-%09%09%09%09
+        
 public void colu
@@ -776,37 +776,42 @@
 ng%5B%5D coldata) %7B%0A
-%09%09%09%09%09
+          
 Log.v(TAG, %22Colu
@@ -842,34 +842,43 @@
 (coldata));%0A
-%09%09%09%09%7D%0A%09%09%09%09
+        %7D%0A%0A        
 @Override%0A%09%09
@@ -871,28 +871,32 @@
   @Override%0A
-%09%09%09%09
+        
 public void 
@@ -915,29 +915,34 @@
 %5B%5D types) %7B%0A
-%09%09%09%09%09
+          
 Log.v(TAG, %22
@@ -981,18 +981,27 @@
 ));%0A
-%09%09%09%09%7D%0A%09%09%09%09
+        %7D%0A%0A        
 @Ove
@@ -1006,20 +1006,24 @@
 verride%0A
-%09%09%09%09
+        
 public b
@@ -1056,21 +1056,26 @@
 data) %7B%0A
-%09%09%09%09%09
+          
 Log.v(TA
@@ -1118,19 +1118,19 @@
 ));%0A
-%09%09%09%09%09%0A%09%09%09%09%09
+%0A          
 // C
@@ -1159,21 +1159,26 @@
 vadoc):%0A
-%09%09%09%09%09
+          
 // %22If t
@@ -1235,13 +1235,18 @@
 d.%22%0A
-%09%09%09%09%09
+          
 retu
@@ -1259,55 +1259,49 @@
 se;%0A
-%09%09%09%09%7D%7D;%0A%09%09%09%09db.exec(%22SELECT load_extension('lib
+        %7D%0A      %7D;%0A      db.exec(%22SELECT 
 spat
@@ -1310,12 +1310,17 @@
 lite
-.so'
+_version(
 );%22,
@@ -1329,183 +1329,85 @@
 b);%0A
-%09%09%09db.exec(%22SELECT name, peoples, AsText(GaiaGeometry) from Towns where peoples %3E 350000 order by peoples DESC;%22, cb);%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%7D%0A
+    %7D catch (Exception e) %7B%0A      Log.e(TAG, %22Exception caught%22, e);%0A    %7D%0A  %7D
 %0A%7D%0A

Test Activity: simplify the test to simple "SELECT spatialite_version();"