gt:         FilenameFilter filter = new FilenameFilter() {
context: package de.smasi.tickmate.database;
  
  import android.content.Context;
  import android.database.SQLException;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  import android.util.Log;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.FilenameFilter;
  import java.io.IOException;
  
  public class DatabaseOpenHelper extends SQLiteOpenHelper {
      private static DatabaseOpenHelper sharedInstance;
  	private Context context;
      private static final String TAG = "DatabaseOpenHelper";
  
      /* Table names */
      public static final String TABLE_TRACKS = "tracks";
      public static final String TABLE_TICKS = "ticks";
      public static final String TABLE_GROUPS = "groups";
      public static final String TABLE_TRACK2GROUPS = "track2groups";
  
      /* Field names */
      public static final String COLUMN_ID = "_id";
      public static final String COLUMN_NAME = "name";
      public static final String COLUMN_DESCRIPTION = "description";
      public static final String COLUMN_ICON = "icon";
      public static final String COLUMN_ENABLED = "enabled";
      public static final String COLUMN_ORDER = "order";
      public static final String COLUMN_YEAR = "year";
      public static final String COLUMN_MONTH = "month";
      public static final String COLUMN_DAY = "day";
      public static final String COLUMN_HOUR = "hour";
      public static final String COLUMN_MINUTE = "minute";
      public static final String COLUMN_SECOND = "second";
      public static final String COLUMN_TRACK_ID = "_track_id";
      public static final String COLUMN_GROUP_ID = "_group_id";
      public static final String COLUMN_MULTIPLE_ENTRIES_PER_DAY = "multiple_entries_per_day";
      public static final String COLUMN_HAS_TIME_INFO = "has_time_info";
      public static final String COLUMN_COLOR = "color";
  
      private static final String DATABASE_NAME = "tickmate.db";
      private static final int DATABASE_VERSION = 14;
      
      public DatabaseOpenHelper(Context context) {
          super(context, DATABASE_NAME, null, DATABASE_VERSION);
          this.context = context;
      }
      
      public static DatabaseOpenHelper getInstance(Context context) {
      	if (sharedInstance == null) {
  			sharedInstance = new DatabaseOpenHelper(context.getApplicationContext());
  		}
      	return sharedInstance;
      }
      
      // Database creation sql statement
      private static final String DATABASE_CREATE_TRACKS = 
      	"create table " + TABLE_TRACKS + "(" 
      	+ COLUMN_ID + " integer primary key autoincrement, "
          + COLUMN_NAME + " text not null, "
          + COLUMN_DESCRIPTION + " text not null, "
          + COLUMN_ICON + " text not null, "
          + COLUMN_ENABLED + " integer not null,"
          + COLUMN_MULTIPLE_ENTRIES_PER_DAY + " integer DEFAULT 0,"
          + COLUMN_COLOR + " integer DEFAULT 0,"
          + "\"" + COLUMN_ORDER + "\" integer DEFAULT -1"
          + ");";
      private static final String DATABASE_CREATE_TICKS =
          "create table " + TABLE_TICKS + "("
          + COLUMN_ID + " integer primary key autoincrement, "
          + COLUMN_TRACK_ID + " integer,"
          + COLUMN_YEAR + " integer,"
          + COLUMN_MONTH + " integer,"
          + COLUMN_DAY + " integer,"
          + COLUMN_HOUR + " integer,"
          + COLUMN_MINUTE + " integer,"
          + COLUMN_SECOND + " integer,"
          + COLUMN_HAS_TIME_INFO + " integer DEFAULT 0"
          + ");";
      private static final String DATABASE_CREATE_GROUPS =
              "create table " + TABLE_GROUPS + "("
                      + COLUMN_ID + " integer primary key autoincrement, "
                      + COLUMN_NAME + " text not null, "
                      + COLUMN_DESCRIPTION + " text not null, "
                      + "\"" + COLUMN_ORDER + "\" integer DEFAULT -1"
                      + ");";
      private static final String DATABASE_CREATE_TRACK2GROUPS =
  			"create table " + TABLE_TRACK2GROUPS + "("
  					+ COLUMN_ID + " integer primary key autoincrement, "
  					+ COLUMN_TRACK_ID + " integer not null, "
                      + COLUMN_GROUP_ID + " integer not null "
                      + ");";
  
  	@Override
  	public void onCreate(SQLiteDatabase db) {
  		Log.d("tickmate", "Creating database");
  		db.execSQL(DATABASE_CREATE_TRACKS);
  		db.execSQL(DATABASE_CREATE_TICKS);
          db.execSQL(DATABASE_CREATE_GROUPS);
          db.execSQL(DATABASE_CREATE_TRACK2GROUPS);
  
  	}
  
  	@Override
  	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  		Log.d("tickmate", "Upgrading database");
          if (oldVersion >= 9 && newVersion <= DATABASE_VERSION) {
  			if (oldVersion <= 9) {
  				Log.d("tickmate", "Migrating database to version 10");
  				db.execSQL("ALTER TABLE " + TABLE_TRACKS + " ADD COLUMN \"" + COLUMN_MULTIPLE_ENTRIES_PER_DAY + "\" integer DEFAULT 0;");
  				
  				db.execSQL("ALTER TABLE " + TABLE_TICKS + " ADD COLUMN \"" + COLUMN_HOUR + "\" integer;");
  				db.execSQL("ALTER TABLE " + TABLE_TICKS + " ADD COLUMN \"" + COLUMN_MINUTE + "\" integer;");
  				db.execSQL("ALTER TABLE " + TABLE_TICKS + " ADD COLUMN \"" + COLUMN_SECOND + "\" integer;");
  				db.execSQL("ALTER TABLE " + TABLE_TICKS + " ADD COLUMN \"" + COLUMN_HAS_TIME_INFO + " integer DEFAULT 0;");
  			}
  			if (oldVersion <= 10) {
  				Log.d("tickmate", "Migrating database to version 11");
  				db.execSQL("ALTER TABLE " + TABLE_TRACKS + " ADD COLUMN \"" + COLUMN_ORDER + "\" integer DEFAULT -1;");			
  			}
  			if (oldVersion == 11) {
  				try {
  					db.execSQL("ALTER TABLE " + TABLE_TRACKS + " ADD COLUMN \"" + COLUMN_ORDER + "\" integer DEFAULT -1;");
  				}
  				catch (SQLException e) {
  					Log.d("tickmate", "Ignoring SQL error: " + e.toString());
  				}
  			}
              if (oldVersion <= 12) {
                  db.execSQL(DATABASE_CREATE_GROUPS);
                  db.execSQL(DATABASE_CREATE_TRACK2GROUPS);
              }
              if (oldVersion <= 13) {
                  Log.d("tickmate", "Migrating database to version 14");
                  db.execSQL("ALTER TABLE " + TABLE_TRACKS + " ADD COLUMN \"" + COLUMN_COLOR + "\" integer DEFAULT " + Integer.toString(0x4ea6e0));
              }
  		} else {
  			db.execSQL("DROP TABLE IF EXISTS " + TABLE_TRACKS);
  		    db.execSQL("DROP TABLE IF EXISTS " + TABLE_TICKS);
  		    onCreate(db);
  		}
  	}
  	
  	private String getDatabasePath() {
  		String db_path = context.getDatabasePath(DATABASE_NAME).getAbsolutePath();
  		Log.v("tickmate", "internal database path: " + db_path);
  		return db_path;
  	}
  	
  	public String getExternalDatabasePath(String name) throws IOException {
  		String db_path = new File(getExternalDatabaseFolder(), name).getAbsolutePath();
  		Log.v("tickmate", "external database path: " + db_path);
  		return db_path;
  	}
  
  	/**
  	 * Copies the database file at the specified location over the current
  	 * internal application database.
  	 * */
  	public boolean exportDatabase(String externalName) throws IOException {
  	    // Close the SQLiteOpenHelper so it will commit the created empty
  	    // database to internal storage.
  	    close();
  	    
  	    File extDb = new File(getExternalDatabasePath(externalName));
  	    File myDb = new File(getDatabasePath());
  	    
  	    FileUtils.copyFile(new FileInputStream(myDb), new FileOutputStream(extDb));
  	    return true;
  	}
  	
  	/**
  	 * Copies the database file at the specified location over the current
  	 * internal application database.
  	 * */
  	public boolean importDatabase(String externalName) throws IOException {
  
  	    // Close the SQLiteOpenHelper so it will commit the created empty
  	    // database to internal storage.
  	    close();
  	    
  	    File extDb = new File(getExternalDatabasePath(externalName));
  	    File myDb = new File(getDatabasePath());
  	    if (extDb.exists()) {
  	        FileUtils.copyFile(new FileInputStream(extDb), new FileOutputStream(myDb));
  	        // Access the copied database so SQLiteHelper will cache it and mark
  	        // it as created.
  	        getWritableDatabase().close();
  	        return true;
  	    }
  	    return false;
  	}
  
  	public String[] getExternalDatabaseNames() {
  		
  		 File ext_dir;
  		try {
  			ext_dir = getExternalDatabaseFolder();
  		} catch (IOException e) {
  			return new String[0];
  		}
  