Code example for AndroidRuntimeException

        // Check if we can access the external storage. 
        String storageState = Environment.getExternalStorageState();
        if (!Environment.MEDIA_MOUNTED.equals(storageState)) {
            // TODO: verify if this is correct behaviour. 
            throw new AndroidRuntimeException("Cannot access storage");
        storageDirectory = context.getExternalFilesDir(null);
    public void close() { 
    public void open() { 
        DatabaseOpener opener = new DatabaseOpener(context);
        db = opener.getWritableDatabase();
Stop searching for code, let great code find you!  Add Codota to your java IDE