2

I want to implement search functionality in my file manager on android. So what I am trying to do is store all the file paths in my application database, and query from there.

But the problem is after initializing the database with file's path, if there is modification in a file's path like a file is deleted then is there a way to know? Is there an intent fired ?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
sanjeev
  • 1,343
  • 3
  • 16
  • 28
  • I doubt it, because of the excistence of the "mediascanner". Whenever I disconnect my USB, the mediascanners is fired to scan for possible new files: if there is an intent that warns you there was a new file, this wouldn't be needed. Now this is just reasoning so I didn't put it in as an answer, but I wouldn't count on finding anything... – Nanne Jun 26 '12 at 10:02
  • can't a check like java.io.File file = new java.io.File(PATHTOYOURCONTEXT , FILE); if (file.exists()) { will not work ? at the time of databaseinitializing – Dheeresh Singh Jun 26 '12 at 10:03
  • 1
    not sure, but maybe `FileObserver` can help: http://developer.android.com/reference/android/os/FileObserver.html – Vit Khudenko Jun 26 '12 at 10:05
  • it will work but suppose a file is created, i need to update my database but how would i know that i have to update my db. what can i do is run a background service to update the db but that will take resources – sanjeev Jun 26 '12 at 10:06
  • @Arhimed i think this should do.:) – sanjeev Jun 26 '12 at 10:07
  • You can use a recursive `FileObservor` – Jared Rummler Aug 22 '15 at 22:25

0 Answers0