Code example for AndroidRuntimeException

0
                FileInputStream stream = new FileInputStream(file);
 
                // Check we can fit the file in memory. 
                int length = (int) file.length();
                if (file.length() > Integer.MAX_VALUE) {
                    throw new AndroidRuntimeException("Image too large to load.");
                } 
 
                byte[] buffer = new byte[length];
                stream.read(buffer);
                return buffer;
 
            } catch (IOException ex) {
                throw new AndroidRuntimeException(ex);
            } 
        } 
 
        /** 
         * Generates a low resolution bitmap (1/4 of the size) that can be used for thumbnails to reduce memory 
         * usage. 
         *