[英]In Android, how do I query MediaStore only for files in a specific path? Or alternatively, only display files in a certain path?
[英]Android Can I use JOIN at mediastore query
有什么方法可以在媒體存儲數據的查詢中使用聯接?
或者還有什么方法可以通過數據庫而不是內容提供者來訪問媒體存儲數據?
謝謝你。
有什么方法可以在媒體存儲數據的查詢中使用聯接?
抱歉,內容提供者查詢無法進行 JOIN。
或者還有什么方法可以通過數據庫而不是內容提供者來訪問媒體存儲數據?
僅當您編寫自己的固件時。
但我認為你可以使用內容提供者的連接。 如果您進行兩個查詢,您可以使用 CursorJoiner 將它們連接起來。 我正在使用它並且效果很好。
Android 文檔的片段:
CursorJoiner joiner = new CursorJoiner(cursorA, keyColumnsofA, cursorB, keyColumnsofB);
for (CursorJointer.Result joinerResult : joiner) {
switch (joinerResult) {
case LEFT:
// handle case where a row in cursorA is unique
break;
case RIGHT:
// handle case where a row in cursorB is unique
break;
case BOTH:
// handle case where a row with the same key is in both cursors
break;
}
}
它與 SQL join 不完全相同,但它很有用。 在每種“情況”中,您都可以使用指向已處理行的兩個游標進行操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.