admin管理员组

文章数量:1533890

2024年6月21日发(作者:)

}

}

public Intent getFileIntent(File file){

// Uri uri = ("/hpf10/");

Uri uri = le(file);

String type = getMIMEType(file);

Log.i("tag", "type="+type);

Intent intent = new Intent("");

egory("T");

gs(_ACTIVITY_NEW_TASK);

aAndType(uri, type);

return intent;

}

public void writeToSDCard(String fileName,InputStream input){

if(ernalStorageState().equals(_MOUNTED)){

File directory=ernalStorageDirectory();

File file=new File(directory,fileName);

// if(()){

// Log.i("tag", "The file has already exists.");

// return;

// }

try {

FileOutputStream fos = new FileOutputStream(file);

byte[] b = new byte[2048];

int j = 0;

while ((j = (b)) != -1) {

(b, 0, j);

}

();

();

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

tackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

tackTrace();

}

}else{

Log.i("tag", "NO SDCard.");

}

}

private String getMIMEType(File f){

String type="";

String fName=e();

/* 取得扩展名 */

String end=ing(dexOf(".")+1,()).toLowerCase();

/* 依扩展名的类型决定MimeType */

if(("pdf")){

type = "application/pdf";//

}

else if(("m4a")||("mp3")||("mid")||

("xmf")||("ogg")||("wav")){

type = "audio/*";

}

else if(("3gp")||("mp4")){

type = "video/*";

}

else if(("jpg")||("gif")||("png")||

("jpeg")||("bmp")){

type = "image/*";

}

else if(("apk")){

/* L_PACKAGES */

type = "application/e-archive";

}

// else if(("pptx")||("ppt")){

// type = "application/-powerpoint";

// }else if(("docx")||("doc")){

// type = "application/-word";

// }else if(("xlsx")||("xls")){

// type = "application/-excel";

// }

本文标签: 文件类型实现功能