androd新增或刪除檔案後電腦端不能實時更新問題

2021-08-04 18:08:52 字數 470 閱讀 9238

android裝置中資訊的讀取是讀取檔案資料庫的,只有在開機或者其他狀態變化(插拔sd卡)時才會掃瞄檔案以更新該資料庫,因此當新增或刪除檔案時(不處於需要重新整理資料庫的狀態中),資料庫中並沒有該條資訊。

使用廣播通知android資料庫更新。

android中的intent有個intent.action_media_scanner_scan_file

的動作,可以通知資料庫重新掃瞄更新檔案。

具體使用如下:

intent intent = new intent(intent.action_media_scanner_scan_file);

intent.setdata(uri.fromfile(file)); // 需要更新的檔案路徑

context.sendbroadcast(intent);

傳送後,就可以實時看到新增或刪除的檔案了。

新增或刪除 HTML dom元素

如需向 html dom 新增新元素,您必須首先建立該元素 元素節點 然後向乙個已存在的元素追加該元素。這是乙個段落。這是另乙個段落。這段 建立新的元素 var para document.createelement p 如需向 元素新增文字,您必須首先建立文字節點。這段 建立了乙個文字節點 var...

mongodb 新增或刪除字段

1 新增乙個欄位.collectionsname 代表表名 新增字段 content。字串型別。db.collectionsname update 2 刪除乙個字段 db.collectionsname update false,true 為缺失 content 鍵的資料 新增鍵content並將新...

python 陣列新增或刪除元素

test a b c d print 未改變的數列 s test 結果 未改變的數列 a b c d 用法 結果 增加函式 extend 擴充套件的意思 用法 test.extend ab ac print 使用extend增加 s test 結果 使用extend增加 a b c d e e ab...