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

122 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,451
  • 4
  • 37
  • 60
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…
12
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
  • 5,837
  • 3
  • 25
  • 39
8
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
  • 768
  • 8
  • 20
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,503
  • 10
  • 70
  • 96
5
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 apps private directory to the famous "Storage Access Framework". As a consequence of that accessing anything via…
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
  • 635
  • 2
  • 10
  • 22
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
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
  • 7,655
  • 6
  • 38
  • 66
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,657
  • 19
  • 33
4
votes
3 answers

Linux + Java + Windows : Check if file copied completely

I have a Java application which monitors a directory for new files and process any new file it sees in the directory. Application needs to run on both linux and windows env. The issue is on linux, when a user manually copies a file in the directory,…
Prashant
  • 142
  • 1
  • 16
4
votes
2 answers

FileObserver not registering CREATE in onEvent

I have a pretty simple implementation of FileObserver: observer = new FileObserver(rootPath+"Pictures") { @Override public void onEvent(int event, String path) { //event &= FileObserver.ALL_EVENTS; …
Blair Holmes
  • 1,305
  • 1
  • 15
  • 28
1
2 3
8 9