本文介绍了在Android中删除文件之前获取通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我想保存已删除的文件,例如Dumpster。我正在使用fileobserver,但它无法正常工作。文件删除后通知。 FileObserver Observer = null; Observer = new FileObserver(observepath) { @ Override public void onEvent( int 事件, String path) { if ((FileObserver.DELETE& event)! = 0 ||(FileObserver.DELETE_SELF& event)!= 0) { Toast.makeText(MainActivity。 this ,path,Toast .LENGTH_SHORT).show(); } } } 这里的Toast消息是在删除文件后我通过调试模式通过放置断点来检查那里。我使用File.delete()删除文件。现在我的问题是在调用file.delete()之后是否可以通知?解决方案 我认为你不能用 FileObserver 做到这一点。因为 FileObserver [ ^ ]来支持该事件。 如果你发现最好的选择有用的东西.. 如何通知我的应用程序已从SDCard(Android)中删除了一个文件? [ ^ ] I want to save the deleted files like Dumpster. I am using the fileobserver, but its not working . Its notifying after the file deletion.FileObserver Observer = null; Observer = new FileObserver(observepath) { @Override public void onEvent(int event, String path) { if ((FileObserver.DELETE & event)!=0 || (FileObserver.DELETE_SELF & event)!=0) { Toast.makeText(MainActivity.this, path, Toast.LENGTH_SHORT).show(); } }}Here the toast message is coming after the file deletion i checked this by debug mode by putting break point there. And i used "File.delete()" to delete the file. Now my question is after invoking the file.delete() is it possible to notify ? 解决方案 I think you cannot do that with FileObserver. Because there is nothing in FileObserver[^] to support that event.Best bet would be if you find something helpful from..How can I notify my application that one file was deleted from the SDCard (Android)?[^] 这篇关于在Android中删除文件之前获取通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-26 06:49