Questions tagged [fileobserver]

A simple abstract class developers can use to detect changes to a directory (nonrecursively) and fire callbacks as a result.

Monitors files (using inotify) to fire an event after files are accessed or changed by any process on the device (including this one). FileObserver is an abstract class; subclasses must implement the event handler onEvent(int, String).

Full Documentation Link: http://developer.android.com/reference/android/os/FileObserver.html

130 questions
32
votes
1 answer

FileObserver does not work on external storage in Android 6.0 Marshmallow (API 23)

I have an app that observes a public directory on external storage with FileObserver. It works fine on Lollipop devices. I want to add support for Marshmallow, so I set up a Nexus 9 tablet with it. On the Marshmallow device, it fails, on Lollipop…
15
votes
3 answers

Receiving Event, if a file was downloaded/ added to download folder

I would like to receive an event whenever a file was added to a specific folder, e.g. the download folder. To reach this I tried 3 different approaches without any success. The target devices are Android 15+. Do you have any experience with any of…
Anthea
  • 3,741
  • 5
  • 40
  • 64
13
votes
2 answers

Android: FileObserver monitors only top directory

According to the documentation, "Each FileObserver instance monitors a single file or directory. If a directory is monitored, events will be triggered for all files and subdirectories inside the monitored directory." My code goes like, …
rahul
  • 6,447
  • 3
  • 31
  • 42
13
votes
2 answers

Observing changes in Android content observer for Audio.Media.EXTERNAL_CONTENT_URI

I am developing an Android app in which I have to detect changes in Android SD card for audio files with the file name, file path and operation performed upon it. Example if I am adding a file in my SD card then I want to know Name of the file…
9
votes
1 answer

How can I get notification of any file being deleted from SD card

I want to create Dumpster like app, for this I want notification when user is deleting any file so that I can save it to my app memory. I used File Observer but it is giving notification after file deletion and in marshmallow it does not notify for…
Divy Soni
  • 824
  • 9
  • 22
8
votes
3 answers

How to replace FileObserver in Android 10?

android.os.FileObserver requires a java.io.File to function. But with Android 10 Google restricted access to everything but your app's private directory due to the famous "Storage Access Framework". Thus, accessing anything via java.io.File breaks…
8
votes
1 answer

FIleObserver and ContentObserver not working in Android Marshmallow

I have issue with both FIleObserver and ContentObserver not working in Android Marshmallow. I am using this thing for detecting changes that happening inside a folder. I set run time permissions for marshmallow. But after that also it shows no…
7
votes
1 answer

How to listen new photos in android?

I need to listen to new images that comes from any source like downloading images, capture new images, other apps download images..etc Is there any listener that will trigger event whenever new photos is added to gallery? I have been searching for…
7
votes
3 answers

FileObserver CREATE or DELETE received only for files

I've registered a FileObserver for a directory. this.observer = new DirectoryObserver(requested.getAbsolutePath(), FileObserver.CREATE | FileObserver.DELETE | FileObserver.DELETE_SELF); this.observer.startWatching(); Tested on KitKat…
Yaroslav Mytkalyk
  • 16,950
  • 10
  • 72
  • 99
6
votes
2 answers

FileObserver -> onEvent(event, path): path is NULL

I want to know when a file is finished writing, and to do that I'm trying to use FileObserver. I'm doing it like this: FileObserver observer = new FileObserver(imageUri.getPath()) { @Override public void onEvent(int event, String…
PX Developer
  • 8,065
  • 7
  • 42
  • 66
5
votes
0 answers

Android FileObserver not working when copying files with MTP on Marshmallow

I have a FileObserver observing ALL_EVENTS (for test purpose) on a folder in the external storage. The FileObserver will trigger for any events originating from the tablet. For example, if my application or another application on the tablet creates…
JM Lord
  • 1,031
  • 1
  • 13
  • 29
5
votes
2 answers

Multiple FileObserver on same file failed

In my application, I have different components, which monitor the particular file in sdcard using FileObservers. So there are two instances of File Observer which observe a single file, say abc.xml for all events. FileObserver fo1 = new…
darthvading
  • 909
  • 2
  • 11
  • 25
5
votes
1 answer

FileObserver is called twice

I'm using a FileObserver to watch a folder in android. When a user modifies or creates a new file in this folder, the FileObserver should do some stuff with this file. The thing is that with the use of the clause FileObserver.MODIFY, every time I…
Fernando
  • 751
  • 2
  • 13
  • 27
5
votes
3 answers

FileObserver modify is not working

This is my code: public class SyncNotifyService extends Service { private final static String TAG = "FileService"; SDCardListener fileObserver = null; @Override public IBinder onBind(Intent intent) { return null; } public File…
5
votes
1 answer

File Observer is not working from intent service

I've found a great class to extend the abstract File Observer class... import android.os.FileObserver; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import…
Osmium USA
  • 1,751
  • 19
  • 37
1
2 3
8 9