Guest User

Untitled

a guest
Jan 16th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. @Override
  2. public Cursor queryRoots(String[] projection) throws FileNotFoundException {
  3. final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
  4. final MatrixCursor.RowBuilder row = result.newRow();
  5. row.add(Root.COLUMN_ROOT_ID, BuildConfig.DOCUMENTS_AUTHORITY);
  6. row.add(Root.COLUMN_ICON, R.drawable.ic_menu_manage);
  7. row.add(Root.COLUMN_TITLE, "Root Title");
  8. row.add(Root.COLUMN_FLAGS, Root.FLAG_SUPPORTS_SEARCH | Root.FLAG_SUPPORTS_RECENTS);
  9. row.add(Root.COLUMN_SUMMARY, "USB Reader");
  10. row.add(Root.COLUMN_DOCUMENT_ID, "/");
  11. row.add(Root.COLUMN_MIME_TYPES, "*/*");
  12.  
  13. Uri rootsUri = DocumentsContract.buildRootsUri(BuildConfig.DOCUMENTS_AUTHORITY);
  14. getContext().getContentResolver().notifyChange(rootsUri, null);
  15. return result;
  16. }
  17.  
  18. */*
  19.  
  20. @Override
  21. public Cursor queryChildDocuments(String parentDocumentId, String[] projection,
  22. String sortOrder) throws FileNotFoundException {
  23. final MatrixCursor result = new
  24. MatrixCursor(resolveDocumentProjection(projection));
  25. String parentDocumenPath = getContext().getFilesDir().getPath() + "/" + parentDocumentId;
  26. File dir = new File(parentDocumenPath);
  27. for (File file : dir.listFiles()) {
  28. String documentId = parentDocumentId + "/" + file.getName();
  29. includeFile(result, documentId);
  30. }
  31.  
  32. return result;
  33. }
  34.  
  35. if (id == R.id.nav_file_explorer) {
  36. Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
  37. startActivityForResult(intent, 1);
  38. }
Add Comment
Please, Sign In to add comment