试图将图像数据写到文本档案中,作为第64号基数,如果该数据库含有大量信息,但如果含有相当一部分信息,则该数据便坠毁了该应用程序,称其除记忆如下:
package com.search.visual;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Environment;
import android.util.Base64;
import android.util.Log;
import android.widget.Toast;
public class SavePhotoTask extends AsyncTask<byte[], String, String>{
String name;
byte[] num;
@Override
protected String doInBackground(byte[]... params) {
// TODO Auto-generated method stub
File photo = new File(Environment.getExternalStorageDirectory(),".vis/image.xml");
name = Base64.encodeToString(params[0], 0);
//return base64String;
if (photo.exists()){
photo.delete();
}
try{
FileWriter fi = new FileWriter(photo.getPath());
fi.write("<Image>
<Data>");
fi.write(name);
fi.write("</Data>
</Image>");
fi.close();
}catch (IOException e) {
// TODO: handle exception
Log.e("pictureDemo","exception", e);
}
return (null);
}
}
究竟是做错事,还是有更好的办法这样做?
事先感谢你