my code

This class will help me to get information(content) from my database server.

Snippet options

Download: Download snippet as
Copy snippet: For this you need a free my code account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

package com.example.bluwif;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;

import android.os.StrictMode;
import android.util.Log;
import android.view.View;

public class ourHTTP extends Activity {

	public String getWebPage(String adress)
	HttpClient httpClient = new DefaultHttpClient();
		HttpGet httpGet = new HttpGet();
		InputStream inputStream = null;
		String response = null;
			URI uri = new URI(adress);
			HttpResponse httpResponse = httpClient.execute(httpGet);

			inputStream = httpResponse.getEntity().getContent();
			Reader reader = new InputStreamReader(inputStream, "UTF-8");
			int inChar;
			StringBuffer stringBuffer = new StringBuffer();
			while((inChar = != -1){
			response = stringBuffer.toString();
		}catch(ClientProtocolException e)
			Log.e(adress, "error");
		}catch(IOException e)
			Log.e(response, "error");
		}catch(URISyntaxException e)
			Log.e(response, "error"); 
		return response;

	public void sendToServer(String temp_send)
		StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
		String method = "register";
		BackgroundTask backgroundTask = new BackgroundTask(this);
		backgroundTask.execute(method, temp_send);


Create a free my code account now.

my code is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.