Index: other-projects/tipple-android/trunk/src/org/greenstone/android/tipple/TippleActivity.java
===================================================================
--- other-projects/tipple-android/trunk/src/org/greenstone/android/tipple/TippleActivity.java	(revision 24256)
+++ other-projects/tipple-android/trunk/src/org/greenstone/android/tipple/TippleActivity.java	(revision 24257)
@@ -1,5 +1,9 @@
 package org.greenstone.android.tipple;
 
+import java.io.DataOutputStream;
 import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Locale;
@@ -21,4 +25,5 @@
 import android.content.Intent;
 import android.content.SharedPreferences;
+import android.content.res.AssetManager;
 import android.location.LocationListener;
 import android.widget.FrameLayout;
@@ -36,5 +41,5 @@
 	
 	// File storage
-	public static String dataDirectory;
+	public static String geodataDirectory;
 	public static String logDirectory;
 	public static String audioDirectory;
@@ -76,4 +81,122 @@
 	
 	
+	protected boolean assetToExternalStorage(String asset_filename, String external_storage_filename)
+	{
+		boolean status = true;
+		
+		try {
+			
+			File external_storage_file = new File(external_storage_filename);
+			if (!external_storage_file.exists()) {
+				// Need to create the /sdcard version
+				
+				AssetManager assetManager = getAssets();
+				
+				InputStream ais = assetManager.open(asset_filename); // ais = asset input stream
+				FileOutputStream fos = new FileOutputStream(external_storage_file); // fos = file output stream
+			
+				byte [] buffer = new byte[1024];
+				
+				int buflen;
+				while ((buflen = ais.read(buffer))>0) {
+			      fos.write(buffer,0,buflen);
+				}
+			    
+				ais.close();
+				fos.close();
+			}
+			
+	    } 
+		catch (Exception e) {
+			e.printStackTrace();
+			status = false;
+		}			
+	    
+		return status;
+	}
+	
+	protected boolean initTippleStore(String location)
+	{
+		
+    	// Locate map data directory
+        File external_root_file = Environment.getExternalStorageDirectory();
+        String external_root = external_root_file.getAbsolutePath();
+        String tipple_store_dir = external_root + "/tipple-store";
+        
+        geodataDirectory = tipple_store_dir + "/geodata/";
+        logDirectory = tipple_store_dir + "/logs/";
+        audioDirectory = tipple_store_dir + "/audio/";
+		
+        File tipple_store_file = new File(tipple_store_dir);
+        if (!tipple_store_file.exists()) {
+        	if (!tipple_store_file.mkdir()) {
+        		System.err.println("Failed to create directory: " + tipple_store_dir);
+        		return false;
+        	}
+        }
+        
+        File geodataDirFile = new File(geodataDirectory);
+        if (!geodataDirFile.exists()) {
+        	if (!geodataDirFile.mkdir()) {
+        		System.err.println("Failed to create directory: " + geodataDirectory);
+        		return false;
+        	}
+        }
+        
+        File logDirFile = new File(logDirectory);
+        if (!logDirFile.exists()) {
+        	if (!logDirFile.mkdir()) {
+        		System.err.println("Failed to create directory: " + logDirectory);
+        		return false;
+        	}
+        }
+        
+        File audioDirFile = new File(audioDirectory);
+        if (!audioDirFile.exists()) {
+        	if (!audioDirFile.mkdir()) {
+        		System.err.println("Failed to create directory: " + audioDirectory);
+        		return false;
+        	}
+        }
+        
+        // dig out the audio files
+        String[] audio_filenames = { "BeepMorseSonar.wav","Ding.wav","DingExtended.wav" };
+        for (String audio_filename: audio_filenames) {
+        	String audio_asset_filename = "audio/" + audio_filename; 
+    		String audio_exstore_filename = audioDirectory + audio_filename;
+    		
+    		if (!assetToExternalStorage(audio_asset_filename,audio_exstore_filename)) {
+    			System.err.println("Failed to transfer asset " + audio_asset_filename + " to " + audio_exstore_filename);
+    			return false;
+    		}
+        }
+        
+        if ((location != null) && (!location.equals(""))) {
+        	// get out map and XML location file
+        
+        	String map_asset_filename = "geodata/" + location + ".map";
+    		String map_exstore_filename = geodataDirectory + location + ".map";
+    		
+    		if (!assetToExternalStorage(map_asset_filename,map_exstore_filename)) {
+    			System.err.println("Failed to transfer asset " + map_asset_filename + " to " + map_exstore_filename);
+    			return false;
+    		}
+    		
+    		String loc_asset_filename = "geodata/" + location + ".loc";
+    		String loc_exstore_filename = geodataDirectory + location + ".loc";
+    		
+    		if (!assetToExternalStorage(loc_asset_filename,loc_exstore_filename)) {
+    			System.err.println("Failed to transfer asset " + loc_asset_filename + " to " + loc_exstore_filename);
+    			return false;
+    		}	
+        }
+		
+        return true;
+	}
+	
+	protected boolean initTippleStore()
+	{
+		return initTippleStore(null);
+	}
 	protected TextView createLongLatView()
 	{
@@ -98,14 +221,29 @@
         map_view.setClickable(true);
         map_view.setBuiltInZoomControls(true);
-        String full_map_filename = dataDirectory + map_filename;
+        String full_map_filename = geodataDirectory + map_filename;
+           
         map_view.setMapFile(full_map_filename);
-        
+       
         LayoutParams map_view_layout 
 			= new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 
 											ViewGroup.LayoutParams.WRAP_CONTENT, 1);
+        
         map_view.setLayoutParams(map_view_layout);
             
      
         return map_view;
+	}
+	
+	protected MapView createMapViewFromAsset(String map_filename)
+	{
+		// Transfer asset to file in dataDirectory if it does not already exist
+	
+		String asset_filename = "geodata" + File.separator + map_filename;
+		String external_storage_filename = geodataDirectory + map_filename;
+		
+		assetToExternalStorage(asset_filename,external_storage_filename);
+		
+		return createMapView(map_filename);
+	 
 	}
 	
@@ -188,11 +326,9 @@
     	System.err.println("*** TippleActivity::onCreate()");
         super.onCreate(savedInstanceState);
-        
-    	// Locate map data directory
-        File external_root_file = Environment.getExternalStorageDirectory();
-        String external_root = external_root_file.getAbsolutePath();
-        dataDirectory = external_root + "/tipple-store/geodata/";
-        logDirectory = external_root + "/tipple-store/logs/";
-        audioDirectory = external_root + "/tipple-store/audio/";
+    
+        if (!initTippleStore("hamilton")) {
+        	System.err.println("Failed to initialize TippleStore on sdcard.  Quiting");
+        	onDestroy();
+        }
         
         // Set up logging
@@ -223,5 +359,7 @@
 		
 		longlat_view_ = createLongLatView();
-        map_view_ = createMapView("new-zealand.map");
+        //map_view_ = createMapView("new-zealand.map");
+        map_view_ = createMapViewFromAsset("hamilton.map");
+        
         text_view_ = createTextView();
         text_map_composite_ = compositTextViewOnMapView(map_view_,text_view_);
@@ -285,5 +423,5 @@
 	        	
 	            // now TTS initialized, init TTS aware place-locations
-	            String loc_filename = dataDirectory + "hamilton.loc";
+	            String loc_filename = geodataDirectory + "hamilton.loc";
 	            tip_location_manager_ = new TipLocationManager(this,audio_player_view_,tts_);
 	            locations_ = tip_location_manager_.loadTour(loc_filename);
Index: other-projects/tipple-android/trunk/src/org/greenstone/android/tipple/TippleLog.java
===================================================================
--- other-projects/tipple-android/trunk/src/org/greenstone/android/tipple/TippleLog.java	(revision 24256)
+++ other-projects/tipple-android/trunk/src/org/greenstone/android/tipple/TippleLog.java	(revision 24257)
@@ -28,6 +28,6 @@
 		log_directory_ = logDirectory;
 		
-		boolean logfile_ok = initLogging();
-	    alertLogging(logfile_ok);
+		//boolean logfile_ok = initLogging();
+	    //alertLogging(logfile_ok);
 	}
 	
