how to write json data to a file in android

view story

http://stackoverflow.com – Can someone explain what is going wrong here I am using following function public void WriteSettings(Context context, String data){ FileOutputStream fOut = null; OutputStreamWriter osw = null; try{ fOut = context.openFileOutput("schemas.json",Context.MODE_APPEND); osw = new OutputStreamWriter(fOut); osw.write(data); osw.flush(); Toast.makeText(context, data+"Data",Toast.LENGTH_SHORT).show(); Toast.makeText(context, "Settings saved",Toast.LENGTH_SHORT).show(); } catch (Exception e) { e.printStackTrace(); Toast. (HowTos)