MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / watchFile

Method watchFile

src/plugins/sdcard/src/android/SDcard.java:213–242  ·  view source on GitHub ↗
(
    final String fileUri,
    final String id,
    final CallbackContext listener
  )

Source from the content-addressed store, hash-verified

211 }
212
213 private void watchFile(
214 final String fileUri,
215 final String id,
216 final CallbackContext listener
217 ) {
218 activity.runOnUiThread(
219 new Runnable() {
220 @Override
221 public void run() {
222 MyFileObserver observer;
223 Uri uri = Uri.parse(fileUri);
224 File file = new File(uri.getPath());
225
226 if (!file.exists()) {
227 listener.error("File not found");
228 return;
229 }
230
231 if (SDK_INT >= 29) {
232 observer = new MyFileObserver(file, listener);
233 } else {
234 observer = new MyFileObserver(fileUri, listener);
235 }
236
237 observer.startObserving();
238 fileObservers.put(id, observer);
239 }
240 }
241 );
242 }
243
244 private void unwatchFile(String id) {
245 MyFileObserver observer = fileObservers.get(id);

Callers 1

executeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected