public boolean removeFilelistener ( String pResourcename ) throws IOException , TTException , ResourceNotExistingException { mFilelistenerToPaths = new HashMap < String , String > ( ) ; File listenerFilePaths = new File ( StorageManager . ROOT_PATH + File . separator + "mapping.data" ) ; getFileListenersFromSystem ( listenerFilePaths ) ; mFilelistenerToPaths . remove ( pResourcename ) ; StorageManager . removeResource ( pResourcename ) ; 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 ; }
You can remove a filelistener from the system identifying it with it s Storagename .