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. Missing/Hidden/Dissappearing Button problem

<Button
   android:id="@+id/attack_ability_button"
   android:layout_width="52dp"
   android:layout_height="52dp"
   android:layout_x="10dp"
   android:layout_y="70dp"/>

final Button attack_ability_button =
(Button)findViewById(R.id.attack_ability_button);
attack_ability_button.setBackgroundDrawable(getResources().getDrawable(R.drawable.attack_any));


My problem is that when I use the attack_any  drawable to create the
button, it just isn't there.
If I change to another image of the same size, the button shows up
just fine.
I've tried replacing the image file, renaming it, resizing it. Always
with the same results.
I tried using the attack_any drawable for another button and it
disappears as well.
I've also tried moving the button and changing its size, but the
problem persists.
I've even tried drawing the background in XML rather than java and it
still will not show up.

attack_any.png is a 60x60px image 1kb in size.

Scroll View
-----Absolute Layout

-- 

2. Setting theme in an activity

Hi All,

This is my  themes.xml file

<resources>

<style name=*"Theme.Blue"* parent=*"android:Theme"*>

<item name=*"android:windowBackground"*>*...@drawable*/bodyimg_blue</item>

<item name=*"android:colorBackground"*>@color/*royalblue*</item>

<item name=*"android:textColor"*>@color/*midnightblue*</item>

<item name=*"android:textViewStyle"*>@style/TextViewBlue</item>

</style>
<resources>
This is main activity code snippet

*public* *void* onCreate(Bundle savedInstanceState) {

*super*.onCreate(savedInstanceState);

setTheme(R.style.Theme_Blue);

setContentView(R.layout.*main_screen*);
...
The background image is not getting loaded but the text color and
textViewStyle got changed.
The background image remains the defalult one -blank screen.
If I am setting the theme in android manifest file then it works properly.
Can anybody tell me the reason for this?

Warm Regards,
Sudeep

-- 

3. Multiple notifications, single icon on notification bar?

4. baterai portable yg bagus

5. 1024x600 screen size in android 2.1

6. habis flash cm 5.0.8 test 1 gak bisa sync p

7. OOT : Belajar Root Android