Home > Mobile >  Through MediaStore access to mobile phones in all the word documents, how to refresh the new documen
Through MediaStore access to mobile phones in all the word documents, how to refresh the new documen

Time:11-25

Word document within the current that can scan to mobile phones, such as the current 10, WeChat friends sent a to me, I again come in scanning, there should be 11, but only 10.

/* ** all captured by the MediaStore docx document 
*/
Private void getAllDocx () {
ContentResolver cr=getContentResolver ();
Uri Uri=MediaStore. Files. GetContentUri (" external ");
String [] the projection=null;
String sortOrder=null;//unordered
String selectionMimeType=MediaStore. Files. FileColumns. MIME_TYPE + "=?" ;
String mimeType=MimeTypeMap. GetSingleton (.) getMimeTypeFromExtension (" docx ");
//String mimeType.=MimeTypeMap getSingleton () getMimeTypeFromExtension (" doc ");
//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
LogUtils. D (" 1426 "+ fileName);
count++;
}
//sendBroadcast (new Intent (Intent. ACTION_MEDIA_SCANNER_FINISHED, Uri, parse (" file://"+ Environment. GetExternalStorageState ())));
LogUtils. D (" 1534 count "+ count);
}

CodePudding user response:

Refresh the system Media usually has the following several ways:

By manipulating the MediaStore class,
Send broadcast update MediaStore,
By manipulating the MediaScannerConnection class,


https://www.cnblogs.com/plokmju/p/android_mediastore.html





  • Related