Private Void Openfile (file F) {intent = New Intent (); intent. addflags (intent. flag_activity_new_task); intent. setaction (Android. content. Intent. action_view ); /* Call getmimetype () to obtain mimetype */ String type = getmimetype (f ); /* Set the intent file and mimetype */ Intent. setdataandtype (URI. fromfile (F), type); startactivity (intent );} /* Determine the method of the mimetype file */ Private String getmimetype (file F) {string type = "" ; String fname = f. getname (); /* Get the extension */ String end = fname. substring (fname. lastindexof ( "." ) + 1, fname. Length (). tolowercase (); /* Depending on the extension type */ If (End. Equals ( "M4a" ) | End. Equals ( "MP3" ) | End. Equals ( "Mid" ) | End. Equals ( "Xmf" ) | End. Equals ( "Ogg" ) | End. Equals ( "WAV" ) {Type = "Audio" ;} Else If (End. Equals ( "3GP" ) | End. Equals ( "MP4" ) {Type = "Video" ;} Else If (End. Equals ( "Jpg" ) | End. Equals ( "GIF" ) | End. Equals ( "PNG" ) | End. Equals ( "Jpeg" ) | End. Equals ( "BMP" ) {Type = "Image" ;} Else If (End. Equals ( "APK" )){/* Android. Permission. install_packages */ Type = "Application/vnd. Android. Package-Archive" ;} Else {Type = "*" ;} /* If it cannot be opened directly, the Software List will pop out to the user */ If (End. Equals ( "APK" )){} Else {Type + = "/*" ;} Return Type ;}