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();
Connect your IDE to all the code out there  Get Codota for Java