package alvintclam; import java.io.File; import java.io.FileOutputStream; import java.io.PrintWriter; import java.net.Inet4Address; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; import javax.servlet.ServletConfig; import com.amazonaws.util.json.JSONException; import com.amazonaws.util.json.JSONObject; import android.os.Environment; public class PhotoTagging { public String saveText(String newJson) { JSONObject json; try { json = new JSONObject(newJson); String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + "/myfile"); myDir.mkdirs(); String fname = json.getString("filename"); File file = new File (myDir, fname); if (file.exists()) file.delete(); try { FileOutputStream f = new FileOutputStream(file); PrintWriter pw = new PrintWriter(f); pw.println(json.getString("text")); pw.flush(); pw.close(); f.close();; return "OK"; } catch (Exception e) { e.printStackTrace(); } } catch (JSONException e1) { e1.printStackTrace(); } return "ERROR"; } }