Code example for MappedByteBuffer

Methods: position

0
            System.gc();// try to force the bytes from the imgIn to be released
  
            //Create a new bitmap to load the bitmap again. Probably the memory will be available. 
//            imgIn = Bitmap.createBitmap(width, height, config); 
            inBitmap = Bitmap.createBitmap(width, height, config);
            map.position(0);
            //load it back from temporary 
//            imgIn.copyPixelsFromBuffer(map); 
            inBitmap.copyPixelsFromBuffer(map);
            //close the temporary file and channel , then delete that also 
            channel.close();
            randomAccessFile.close();
  
            // delete the temp file 
            file.delete();
  
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }