1

In my application i have created an application form. In one of the page, i have placed 4 layouts.First is to be the root Absolute layout where the background image placed. 2nd is the table layout in which i have placed 3 edit text boxes, next is an absolute layout where i am trying to display the latitude and longitude value. Final is an absolute layout, where i have placed an OK button.

if the ok button is pressed i want to create a database for the data entered in the edit text box and the longitude latitude values

how to create a database for the data entered in the edit text boxes...

pls help me..

RAAAAM
  • 3,378
  • 19
  • 59
  • 108
Siva K
  • 4,968
  • 14
  • 82
  • 161
  • possible duplicate of [how to create database in android](http://stackoverflow.com/questions/2729438/how-to-create-database-in-android) – Quintin Robinson Mar 19 '11 at 04:41

2 Answers2

4

1) AbsoluteLayout is deprecated. Use RelativeLayout instead. http://developer.android.com/reference/android/widget/AbsoluteLayout.html

2) http://developer.android.com/guide/topics/data/data-storage.html#db pretty much covers the DB creation.

You create a helper class extending the Android-provided SQLiteOpenHelper and override the onCreate. Then just create an instance of that class inside your main Activity. For the example on the webpage, this would be:

DictionaryOpenHelper mSQL = new DictionaryOpenHelper(this);

Then you can call getWriteableDatabase(); and getReadadableDatabase(); on that object.

SQLiteDatabase db = mSQL.getWriteableDatabase();

Then you just use the built-in functionality to insert values which you will grab from your EditText fields. An example of how the insert statement looks for me (I run it in a background thread now though, to avoid doing Database-intensive things on the UI thread):

/** SQL insert statement */
private void addIP(String string) {
    SQLiteDatabase db = sql.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(IP_DB, string);
    values.put(TIME, System.currentTimeMillis());
    db.insert(TABLE_NAME, null, values);
}

Read up on Databases in Android and you'll be fine.

Codemonkey
  • 3,412
  • 3
  • 20
  • 24
0

For Database Table creation take a look at this....

Venky
  • 11,049
  • 5
  • 49
  • 66