Home > Mobile > All PDF files within about through MediaStore access to mobile phones
All PDF files within about through MediaStore access to mobile phones
Time:09-26
Like me by the following code to the mobile phone in the PDF file, but I tried it on, such as the first time in the search to mobile phones has 10 PDF file, I quit, and then let the WeChat friend send me a PDF, I open the PDF, I confirm that the PDF has been stored in the phone, then open the search PDF Activity, then there should be 11 PDF file, but still only 10 PDF files, this how to solve? In the search on the net, is not add files to the MediaStore inside, but should be how to operate? Had better have the code, thank you
/* ** all captured by the MediaStore PDF */ Private void getAllPdf () { ContentResolver cr=getActivity (). GetContentResolver (); Uri Uri=MediaStore. Files. GetContentUri (" external "); String [] the projection=null; String selection.=MediaStore Files. FileColumns. MEDIA_TYPE + "=" + MediaStore. Files. FileColumns. MEDIA_TYPE_NONE; String [] selectionArgs=null;//there is no? In the selection so null here String sortOrder=null;//unordered Cursor allNonMediaFiles=cr. Query (uri, the projection, selection, selectionArgs, sortOrder); //only PDF String selectionMimeType=MediaStore. Files. FileColumns. MIME_TYPE + "=?" ; String mimeType=MimeTypeMap. GetSingleton (.) getMimeTypeFromExtension (" PDF "); String [] selectionArgsPdf=new String [] {mimeType}; Cursor Cursor=cr. Query (uri, the projection, selectionMimeType selectionArgsPdf, sortOrder); While (cursor. MoveToNext ()) { Int column_index=cursor. GetColumnIndexOrThrow (MediaStore. Images. Media. The DATA). String filePath=cursor. Get String (column_index);//all PDF file path The String fileName=getFileNameWithSuffix (filePath);//all file name } }
CodePudding user response:
You confirm WeChat receives the PDF is stored in the content://external? Terminals can find way to confirm receive the PDF file storage path, Then print up the filePath above, a look, compare,
CodePudding user response:
If you confirm the storage to the content://external, namely external storage medium, you directly using the File class list to find can also, System when scanning the external media for storage time not too clear,