Saqi

Saqi

  • NA
  • 63
  • 122.3k

How to pass int to string value in Void function

May 15 2012 11:04 AM
check void function i want help that how can send values in void function becouse here is error ...



package xml.writer;

import android.R.integer;
import android.R.string;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.util.Xml;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import java.io.*;
import org.xmlpull.v1.XmlSerializer;



public class MainActivity
extends Activity

{
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
 



save_b.setOnClickListener(new Button.OnClickListener() {
  public void onClick(View arg0)
  {


  MainActivity mainact = new MainActivity();
  EditText  n=(EditText)findViewById(R.id.Nome);
  EditText  numero_d=(EditText)findViewById(R.id.numero_domicilio);
  EditText  nasci=(EditText)findViewById(R.id.data_nasci);
  EditText  mort=(EditText)findViewById(R.id.data_morte);
  EditText  sexo=(EditText)findViewById(R.id.Feminino);
  EditText  sexo_m=(EditText)findViewById(R.id.Masculino);
  EditText  escolaridad=(EditText)findViewById(R.id.Escolaridade);
  EditText  estado_alt=(EditText)findViewById(R.id.estuda_altuamento);

  mainact.create_xml(n, null, null, null, null, null, null); 
 
 }});}


private void create_xml(string n,string n_d ,string nasci,string mort,
  string sexo,string escolaridad,string estado_alt)
  {
 
  File newxmlfile = new File("/sdcard/domicil.xml");
  try{
  if(!newxmlfile.exists())
  {
  newxmlfile.createNewFile();
  }
 }catch(Exception e)
  {
  e.printStackTrace();
  }
  FileOutputStream fileos = null; 
  try{
  fileos = new FileOutputStream(newxmlfile);
  }catch(FileNotFoundException e){
  Log.e("FileNotFoundException", "can't create FileOutputStream");
  }
  //we create a XmlSerializer in order to write xml data
  XmlSerializer serializer = Xml.newSerializer();
  try { 
  // serializer.setOutput(fileos, "UTF-8");
  // serializer.startDocument(null, Boolean.valueOf(true));
  serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
  serializer.startTag(null, "Invidual");
 
  serializer.startTag(null, "Name");
  serializer.text(n);
  serializer.endTag(null, "Name");
  serializer.startTag(null, "Numero_domicilio");
  serializer.text(n_d.toString());
  serializer.endTag(null, "Numero_domicilio");
 
 
  serializer.endDocument();
  serializer.flush();
  fileos.close();
  }
  catch (Exception e)
  {
  Log.e("Exception","error occurred while creating xml file");
  e.printStackTrace();
  }

  }