I'm running into a problem using a FileObserver to update a meta-database when new sqlites are added to a specific directory on the SD card. If I manually adb push a new sqlite to the directory, then call onEvent(FileObserver.CREATE, <filename>)
, it works perfectly. However, when I call FileObserver.startWatching()
and adb push a new sqlite for the observer to catch on its own, it calls onEvent
(with the same params as when I call it manually - I checked), opens the sqlite file fine, but fails to find any of its tables when I query the newly opened sqlite and throws a sqlite exception.
I'm using SQLiteDatabase's openDatabase()
method, so it's not failing to find the original and creating an empty one (a common problem). Additionally, the same sqlite query made in the adb shell accesses the newly added sqlite's tables just fine.
Does anybody have any ideas why this might happen? My code seems to work fine based on the success of the manual call, so I'm looking for any quirks with FileObservers or SQLite on Android that I might have missed, as I'm new to both.
UPDATE: Further debugging shows that if I adb push a file and call onEvent(FileObserver.CREATE, <filename>)
manually, then start the FileObserver watching and adb push the same file to the same location, the FileObserver executes those onEvent
queries with no trouble locating the tables... not sure what this means.