将网页存储在您的资产文件夹中并使用
public File getfile(String filename) throws IOException {
// TODO Auto-generated method stub
String externalStorage_path =Environment.getExternalStorageDirectory().toString();
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)){
File dir = new File(externalStorage_path + "/yourfilename");
dir.mkdir();
File mfile = new File(dir,filename);
if( mfile.exists()==true) return mfile;
else{
try{
InputStream myInput = mcontext.getAssets().open(filename);
String path =externalStorage_path+"/yourfilename";
OutputStream myOutput = new FileOutputStream (path);
byte[] buffer = new byte[1024];
int length;
try {
while((length = myInput.read(buffer))>0)
myOutput.write(buffer,0,length);
}catch(FileNotFoundException e){Log.d("error",""+ e.toString());
}finally{
myOutput.flush();
myOutput.close();
myInput.close();
}
}catch(IOException e){ }
File dir1 = new File(externalStorage_path + "/yourfilename");
dir1.mkdir();
File mfile1 = new File(dir,filename);
return mfile1;
}
}else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)){
showToast("External storage has readonly access");
} else if (Environment.MEDIA_REMOVED.equals(state)) {
showToast("External storage not present");
} else if (Environment.MEDIA_UNMOUNTABLE.equals(state)){
showToast("External storage cannot be mounted. Sdcard problem");
}
这会将文件写入您的存储中,并且可以由其他应用程序(如 Adobe)共享以打开。只是调用了这个方法。