/** * @param context the {@link Context} to use. * @return the db. * @throws IOException if something goes wrong. */ public SQLiteDatabase getDatabase(Context context) throws IOException { File databaseFile; try { databaseFile = ResourcesManager.getInstance(context).getDatabaseFile(); } catch (Exception e) { throw new IOException(e.getLocalizedMessage()); } if (databaseHelper == null || !databaseFile.exists()) { databaseHelper = new DatabaseOpenHelper(databaseFile); SQLiteDatabase db = databaseHelper.getWritableDatabase(context); if (GPLog.LOG_ANDROID) { Log.i(DEBUG_TAG, "Database: " + db.getPath()); Log.i(DEBUG_TAG, "Database Version: " + db.getVersion()); Log.i(DEBUG_TAG, "Database Page Size: " + db.getPageSize()); Log.i(DEBUG_TAG, "Database Max Size: " + db.getMaximumSize()); Log.i(DEBUG_TAG, "Database Open? " + db.isOpen()); Log.i(DEBUG_TAG, "Database readonly? " + db.isReadOnly()); Log.i(DEBUG_TAG, "Database Locked by current thread? " + db.isDbLockedByCurrentThread()); } } return databaseHelper.getWritableDatabase(context); }
@Override public void onClick(View view) { try { File sdcardDir = ResourcesManager.getInstance(getContext()).getSdcardDir(); Intent browseIntent = new Intent(getContext(), DirectoryBrowserActivity.class); browseIntent.putExtra( DirectoryBrowserActivity.PUT_PATH_PREFERENCE, PREFS_KEY_CUSTOM_MAPSFOLDER); browseIntent.putExtra(DirectoryBrowserActivity.EXTENSIONS, DirectoryBrowserActivity.FOLDER); browseIntent.putExtra(DirectoryBrowserActivity.STARTFOLDERPATH, sdcardDir.getAbsolutePath()); context.startActivity(browseIntent); } catch (Exception e) { GPLog.error(this, null, e); // $NON-NLS-1$ } }