Problem with insertion into SqLite Database..

by Raihan Jamal » Wed, 21 Apr 2010 06:22:00 GMT

Sponsored Links
 hanks for replying...
I am having one more problem now...
I am using this below java file to create a database and table on the
click event of Create DB Button[b][i]( till here it is working fine)[/
i] [/b]and then below this Create DB button, there is one more button
named Send Button... and on the click event of Send Button I am
opening another activity which contains a edit text and a button
called Insert[i][b](this is also working fine for me)[/b][/i] and on
the click event of this Insert Button... I have to insert the value
that we are typing into edit text box into the table that we have
created previously.... but I am not able to figure it out why it is
not inserting into table that we have created previously... what wrong
I am doing please let me know.... Below are the codes....
[size=18]This Code contains Create DB Button and Send Button and click
event also that are creating tables and database
package com.example.hw3;

import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class HW3 extends Activity {
private Button b1;
private Button b2;
private A1 test;
private EditText text;

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
text = (EditText) findViewById(;

protected void initControls()
b1 = (Button)findViewById(;
b2 = (Button)findViewById(;

b1.setOnClickListener(new Button.OnClickListener()
{ public void onClick (View v){ DoWork(); }});

b2.setOnClickListener(new Button.OnClickListener()
{ public void onClick (View v){
Intent myIntent = new Intent(HW3.this, A1.class);
// HW3.this.startActivity(myIntent);


protected void DoWork()

// SQLiteDatabase db=null;

// db1 = new HW3DbAdapter(this);
text.setText("Button 1 was clicked");

SQLiteDatabase myDB= null;
String TableName = "db_entry";

/* Create a Database. */
try {
myDB = this.openOrCreateDatabase("db_hw3", MODE_PRIVATE,
myDB.execSQL("DROP TABLE IF EXISTS db_entry" );
/* Create a Table in the Database. */
+ TableName
NULL,ph_location TEXT);");

catch(Exception e) {
Log.e("Error", "Error", e);
} finally {
if (myDB != null)


} [/code]

This is the Code for an Activity that contain edit text and Insert
Button....I think something wrong I am doing in the try block of this
code..... Please help[/size]

[code] package com.exampl

Other Threads

1. Context menu can't be create on MapView.

hi all
    I want to create a context menu when LongClick is hitted. As
result mapview is opened successfully; but the LongClick got no
response. Would you like to give me a hand how to solve it? Below is
the complete code. Thank you very much.

package android.demo;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.View;
import android.util.*;
public class demo extends MapActivity {
    /** Called when the activity is first created. */
        MapView mapView;
    public void onCreate(Bundle savedInstanceState) {
        mapView = (MapView) findViewById(;
        // We also want to show context menu for longpressed items in
the gallery
      //init the map view

        mapView.setOnLongClickListener(new View.OnLongClickListener(){

        public boolean onLongClick(View v) {
        return true;


View.OnCreateContextMenuListener() {
        public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo) {
              menu.add(0, 1, 0, "Add");
              menu.add(0, 2, 0, "Delete");
              menu.add(0, 3, 0, "Edit");



    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;

2. Will Android support Arabic language?

I would like to know if there is a plan to include Arabic language in
the next release of Android OS, since most google web services support
Arabic language. The Arabian users hope that the next version of
Android will be able to support Arabic language without installing any
third party applications. Thank you in advance and I hope to see your
PDAs in our markets as soon as possible.


3. using an intent to react when an sms is sent?

4. Usability question: How is user supposed to discover the menu shortcut keys?

5. Taking payments (google checkout)

6. Charge for Apps (What will Happen?)

7. ToolBar