private String saveCrashInfo2File(Throwable ex) {
		StringWriter writer = new StringWriter();
		PrintWriter printWriter = new PrintWriter(writer);
		ex.printStackTrace(printWriter);
		writer.append("\n-------feng-ge-xian-------\n\n");

		Throwable cause = ex.getCause();
		while (cause != null) {
			cause.printStackTrace(printWriter);
			writer.append("\n-------feng-ge-xian-------\n\n");
			cause = cause.getCause();
		}
		printWriter.close();

		// 通过StringBuffer处理信息
		StringBuffer sb = new StringBuffer();
		// 设备信息
		for (Map.Entry<String, String> entry : crashInfos.entrySet()) {
			sb.append(entry.getKey() + "=" + entry.getValue() + "\n");
		}
		// 异常信息
		// sb.append(printWriter.toString());
		sb.append(writer.toString());
		// 保存到文件
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS",
				Locale.CHINA);
		String dateStr = sdf.format(new Date());
		String fileName = dateStr + ".log";
		if (Environment.getExternalStorageState().equals(
				Environment.MEDIA_MOUNTED)) {
			File dir = new File(Environment.getExternalStorageDirectory()
					.getAbsolutePath() + "/iCam/Crash/");// crash后面的/加不加都一样,dir都不含"/"
			if (!dir.exists()) {
				dir.mkdirs();
				Log.i(TAG, dir.toString());
			}
			try {
				FileOutputStream fos = new FileOutputStream(dir + "/"
						+ fileName);
				fos.write(sb.toString().getBytes());
				fos.close();
				return fileName;
			} catch (IOException e) {
				Log.e(TAG, "an error occured while writing file...", e);
			}

		}
		return null;

	}