|
|
@ -88,10 +88,8 @@ object DocumentUtils { |
|
|
|
val docList = arrayListOf<DocItem>() |
|
|
|
val docList = arrayListOf<DocItem>() |
|
|
|
var c: Cursor? = null |
|
|
|
var c: Cursor? = null |
|
|
|
try { |
|
|
|
try { |
|
|
|
val childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree( |
|
|
|
val childrenUri = DocumentsContract |
|
|
|
uri, |
|
|
|
.buildChildDocumentsUriUsingTree(uri, DocumentsContract.getDocumentId(uri)) |
|
|
|
DocumentsContract.getDocumentId(uri) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
c = context.contentResolver.query( |
|
|
|
c = context.contentResolver.query( |
|
|
|
childrenUri, arrayOf( |
|
|
|
childrenUri, arrayOf( |
|
|
|
DocumentsContract.Document.COLUMN_DOCUMENT_ID, |
|
|
|
DocumentsContract.Document.COLUMN_DOCUMENT_ID, |
|
|
@ -107,17 +105,18 @@ object DocumentUtils { |
|
|
|
val sci = c.getColumnIndex(DocumentsContract.Document.COLUMN_SIZE) |
|
|
|
val sci = c.getColumnIndex(DocumentsContract.Document.COLUMN_SIZE) |
|
|
|
val mci = c.getColumnIndex(DocumentsContract.Document.COLUMN_MIME_TYPE) |
|
|
|
val mci = c.getColumnIndex(DocumentsContract.Document.COLUMN_MIME_TYPE) |
|
|
|
val dci = c.getColumnIndex(DocumentsContract.Document.COLUMN_LAST_MODIFIED) |
|
|
|
val dci = c.getColumnIndex(DocumentsContract.Document.COLUMN_LAST_MODIFIED) |
|
|
|
c.moveToFirst() |
|
|
|
if (c.moveToFirst()) { |
|
|
|
do { |
|
|
|
do { |
|
|
|
val item = DocItem( |
|
|
|
val item = DocItem( |
|
|
|
name = c.getString(nci), |
|
|
|
name = c.getString(nci), |
|
|
|
attr = c.getString(mci), |
|
|
|
attr = c.getString(mci), |
|
|
|
size = c.getLong(sci), |
|
|
|
size = c.getLong(sci), |
|
|
|
date = Date(c.getLong(dci)), |
|
|
|
date = Date(c.getLong(dci)), |
|
|
|
uri = DocumentsContract.buildDocumentUriUsingTree(uri, c.getString(ici)) |
|
|
|
uri = DocumentsContract.buildDocumentUriUsingTree(uri, c.getString(ici)) |
|
|
|
) |
|
|
|
) |
|
|
|
docList.add(item) |
|
|
|
docList.add(item) |
|
|
|
} while (c.moveToNext()) |
|
|
|
} while (c.moveToNext()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
e.printStackTrace() |
|
|
|
e.printStackTrace() |
|
|
|