Code example for FileChannel

Methods: map

0
                return false; 
            } 
 
            // Map index file to memory 
            mIndexChannel = mIndexFile.getChannel();
            mIndexBuffer = mIndexChannel.map(FileChannel.MapMode.READ_WRITE,
                    0, mIndexFile.length());
            mIndexBuffer.order(ByteOrder.LITTLE_ENDIAN);
 
            setActiveVariables(); 
            return true; 
        } catch (IOException ex) {
            Log.e(TAG, "loadIndex failed.", ex);
            return false; 
        } 
    } 
 
    private void setActiveVariables() throws IOException { 
        mActiveDataFile = (mActiveRegion == 0) ? mDataFile0 : mDataFile1;
        mInactiveDataFile = (mActiveRegion == 1) ? mDataFile0 : mDataFile1;
        mActiveDataFile.setLength(mActiveBytes);