Here is my FileObserver code:
private void updatecheck() {
// Email sync loop
mHandler.post(new Runnable() {
@Override
public void run() {
if (Looper.myLooper() == null) {
Looper.prepare();
}
FileObserver observerGAD7 = new FileObserver(String.valueOf(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS + "/GAD7_Client_Responses.db"))) {
@Override
public void onEvent(int event, String path) {
if ((FileObserver.MODIFY & event)!=0) {
System.out.println("GAD7 file event");
//TODO EMAIL GAD7 DATABASE AUTOMATICALLY
}
}
};
observerGAD7.startWatching();
FileObserver observerPHQ9 = new FileObserver(String.valueOf(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS + "/PHQ9_Client_Responses.db"))) {
@Override
public void onEvent(int event, String path) {
if ((FileObserver.MODIFY & event)!=0) {
System.out.println("PHQ9 file event");
//TODO EMAIL PHQ9 DATABASE AUTOMATICALLY
}
// Looper.myLooper().quit();
}
};
observerPHQ9.startWatching();
Looper.loop();
}
});
}
It is returning 2 reports to log rather than just one. This would mean that 2 automatic emails, once implemented, would be sent which isn't ideal.
Can anyone help me with my syntax?