android - Best way to get all documents from mobile? -
i want types of documents pdf,xml,doc except video , image , audio files.
and display list name, size, date, , location.
contentresolver cr = context.getcontentresolver(); uri uri = mediastore.files.getcontenturi("external"); // every column, although huge waste, need // basecolumns.data (the path) only. string[] projection = null; // exclude media files, here also. string selection = mediastore.files.filecolumns.media_type + "=" + mediastore.files.filecolumns.media_type_none; string[] selectionargs = null; // there no ? in selection null here string sortorder = null; // unordered cursor allnonmediafiles = cr.query(uri, projection, selection, selectionargs, sortorder);
i using code getting documents mobile work? , how document details uri, date, , name. advance.
try one:
file path; arraylist<string> pdf_paths=new arraylist<string>(); arraylist<string> pdf_names=new arraylist<string>(); path = new file(environment.getexternalstoragedirectory() + ""); searchfolderrecursive1(path); private static void searchfolderrecursive1(file folder) { if (file.isfile()) { //.pdf files if(file.getname().contains(".pdf")) { file.getpath(); pdf_names.add(file.getname()); pdf_paths.add(file.getpath()); log.e("pdf_paths", ""+pdf_names); } else if(file.getname().contains(".doc")) { file.getpath(); pdf_names.add(file.getname()); pdf_paths.add(file.getpath()); } } }
Comments
Post a Comment