public static boolean addFilelistener ( String pResourcename , String pListenerPath ) throws FileNotFoundException , IOException , ClassNotFoundException { mFilelistenerToPaths = new HashMap < String , String > ( ) ; File listenerFilePaths = new File ( StorageManager . ROOT_PATH + File . separator + "mapping.data" ) ; getFileListenersFromSystem ( listenerFilePaths ) ; mFilelistenerToPaths . put ( pResourcename , pListenerPath ) ; ByteArrayDataOutput output = ByteStreams . newDataOutput ( ) ; for ( Entry < String , String > e : mFilelistenerToPaths . entrySet ( ) ) { output . write ( ( e . getKey ( ) + "\n" ) . getBytes ( ) ) ; output . write ( ( e . getValue ( ) + "\n" ) . getBytes ( ) ) ; } java . nio . file . Files . write ( listenerFilePaths . toPath ( ) , output . toByteArray ( ) , StandardOpenOption . TRUNCATE_EXISTING ) ; return true ; }
Add a new filelistener to the system .