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
[/size]
[code]
package com.example.hw3;


import android.app.Activity;
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;
@SuppressWarnings("unused")
private A1 test;
private EditText text;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text = (EditText) findViewById(R.id.EditText01);
initControls();
}

protected void initControls()
{
b1 = (Button)findViewById(R.id.CreateDB);
b2 = (Button)findViewById(R.id.Button02);





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);
startActivity(myIntent);
}});


}


protected void DoWork()
{

// SQLiteDatabase db=null;

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

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

/* Create a Database. */
try {
myDB = this.openOrCreateDatabase("db_hw3", MODE_PRIVATE,
null);
myDB.execSQL("DROP TABLE IF EXISTS db_entry" );
/* Create a Table in the Database. */
myDB.execSQL("CREATE TABLE IF NOT EXISTS "
+ TableName
+ " (id INTEGER PRIMARY KEY AUTOINCREMENT, mb_text TEXT NOT
NULL,ph_location TEXT);");

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


}



} [/code]


------------------
[size=18]
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. Could this happen on Android?

I have my main handler and a blockingQueue. Messages are added to the
blockingQueue from another thread so not to overload the handler with
messages. The messages are processed by the handler as they come in.

My concern is if the handler stops processing messages and queue is
full, then my thread will continue to wait (unless interrupted). Could
it happen on Android that the main handler exits (for whatever reason)
and leaves the other threads intact? I'm guessing no, but I'd like
some confirmation on this. I have written some stuff to handle this
situation but am I being overly cautious?

-- 

2. Android keyevent keycodes and scancodes

Hi
I am writing a program which captures the keys pressed by user in
android and displays it in Ubuntu. According to what I read, Android's
input event device is structured around an interrupt or polling
routine that captures the device-specific scancode and converts it to
a standard form acceptable to Linux (as defined in input.h) before
passing it to the kernel with input_event(). There are the steps which
describe the translation from keyboard input to application action:
1. Window manager reads key event from Linux keyboard driver.
2. Window manager maps scancode to keycode.
3. Window manager sends both the scancode and the keycode to the
application.

Now in my application I have an EditText which returns the keycode of
any key which is pressed. So basically this is what I have:
                        public boolean onKey(View v, int keyCode, KeyEvent 
event) {
                                // TODO Auto-generated method stub
                                String a ="";a+=keyCode;
                                txt.setText(a);

                                return false;
                        }

Now I get this keycode value but it does not correspond to the
scancode value. For example, the keycode value for 'A' is 29 but the
scancode is 30. There is no correlation I can see between the input.h
scancodes and these keycodes either. My question is, I want to know
how step 2 (the mapping) above takes place. My applications aim is to
echo whatever I type on my android keyboard on my Ubuntu desktop (I
can connect between the 2 without a problem, so you don't have to
worry about that). Any help would be appreciated, as I have looked
online for quite a bit.

-- 

3. OnScrollListener#onScrollStateChanged cange behavior from 1.5?

4. Is status bar an activity?

5. Android on Samsung s3c6410 accessing rs232 serial port

6. Android Eclair -- hangs after gralloc/mapFrameBufferLocked

7. Cannot start volume '/sdcard' (volume is not bound) error using vold