by Hanly on Jan.07, 2010, under Tutorials
This tutorial will demonstrate how to use the database adapter created in "Creating a SQLite Database in Android" to add and get data to and from the database to populate a ListView.
DatabaseQuery.java :
We must first create a class to handle the formatting for the queries. The database adapter takes ArrayLists of String objetcs to add rows to the database, however you will probably want a method to add one cell at a time, then when the contents of the row are completed, add the entire row to the database. We begin by declaring the variables for the ArrayLists.
import java.util.ArrayList;
import android.content.Context;
import android.database.Cursor;
/**
* This class adds multiple entries to the database and pulls them back
* out.
*/
public class DatabaseQuery ...
(continue reading...)
:android, database, database adapter, howto, sqlite, step-by-step, tutorial, using database adapter, using dbadapter
more...
by Hanly on Dec.24, 2009, under Tutorials
There are several ways to send data across the internet to a server on the Android. I was recently working on a project and needed to send a JSON string to the server to add data to a database. Additionally in certain cases I wanted to receive data back from the server. The fastest and easiest way to do this was to use HTTP POST android library and capture the response from the server using a response handler. On the server side the response was simply generated by echoing a JSON string.
public ArrayList<String> getServerData() throws JSONException, ClientProtocolException, IOException {
ArrayList<String> stringData = new ArrayList<String>();
DefaultHttpClient httpClient = new DefaultHttpClient();
ResponseHandler <String> resonseHandler = new BasicResponseHandler();
HttpPost ...
(continue reading...)
:android, database, howto, http, java, JSON, mysql, PHP, POST, server, tutorial
more...