Question

Specifically I am looking for a way to update the current view of my app (which displays media files) based on whether new files are added or deleted in the background, or when the app is in a paused state.

The only way I know of is the query the MediaStore and check the count of the returned tuples, and recreate the whole view if counts are different. Ofcourse this has certain caveats.

Is there a way so that I can establish a call-back when certain type of files are written or removed from a certain directory ?

TIA

Was it helpful?

Solution

On Linux, people use inotify to achieve this goal,

And in Android, we can use FileObserver:

See the ref here:

http://www.roman10.net/android-fileobserverthe-underlying-inotify-mechanism-and-an-example/

Android file system hooks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top