Code example for AndroidRuntimeException

0
 
        // 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() { 
        db.close();
    } 
 
    public void open() { 
        DatabaseOpener opener = new DatabaseOpener(context);
        db = opener.getWritableDatabase();
    } 
 
    private long getToday() {