I'm retrieving a picture file as binary code through ajax, then javascript passes it to java on android and android is getting the binary code but I can't make it save it... I have tried many diiferent ways and nothing works.
the code on java so far looks like this:
public void setFile(String sFileName, String sBody){
try
{
//Log.w("setfile", sBody);
File root = new File(Environment.getExternalStorageDirectory(), local_address);
if (!root.exists()) {
root.mkdirs();
}
File gpxfile = new File(root, sFileName);
FileOutputStream aFileOutStream = new FileOutputStream(gpxfile);
DataOutputStream aDataOutputStream = new DataOutputStream(aFileOutStream);
aDataOutputStream.writeUTF(sBody);
aDataOutputStream.flush();
aDataOutputStream.close();
aFileOutStream.close();
//FileWriter writer = new FileWriter(gpxfile);
//writer.append(sBody);
//writer.flush();
//writer.close();
//Toast.makeText(this, "Saved", Toast.LENGTH_SHORT).show();
}
catch(IOException e)
{
e.printStackTrace();
}
}
i know java is working because if I uncomment this line
//Log.w("setfile", sBody);
log cat would return the binary code that javascript sent java