Code example for Formatter

Methods: format, toString

0
	//create a new user on rails server.  
	private long newUser(String u){
		//set up the request 
		HttpPost request = new HttpPost();
		Object[] values = {u};
		Formatter f = new Formatter();
		f.format("user[email]=%s&commit=Create User", values);
		//set up the query 
		String data = f.toString();
 
		URI url;
		try {  
			url = new URI("http", "happytrack.heroku.com", "/users.json", data, null); 
			//visit this url using POST (note, will not work with GET) 
			//http://happytrack.heroku.com/users.json?user[email]=sayhar@gmail.com 
			request.setURI(url);
			Log.d(TAG, "data: "+ data);
			Log.d(TAG, "uRL: " + url);
		} catch (URISyntaxException e1) {
 
			e1.printStackTrace();