Use of SQLiteOpenHelper class for using SQLite

by Neo » Tue, 02 Mar 2010 22:22:48 GMT

Sponsored Links
 ello ppl,

I am trying to create an application similar to login form where user
can register themselves for username, password, email etc.The
functionality is as follows.
When the user comes to this app it will be ask to either register or
login. In case of user registering himself he enters firstname,
lastname, username, password and email id using EditText.
On hitting the submit button it should be forwarded to another screen
where he sees his details like username, email etc
I am using SQLite for persisting the data and taking help of
SQLiteOpenHelper for the same. It seems that I am able to create
database and table but no able to insert any values in it. The stack
traces shows that I have an unhandled NullPointer exception

The help class called DatabaseHelper is defined as follows


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.widget.Toast;

public class DatabaseHelper extends SQLiteOpenHelper

public static final int DB_version = 1;
public static final String DB_name = "User";
public SQLiteDatabase database;
public static final String TABLE_NAME = "tbl_users";
//public static final String TABLE_NAME = "tbl_temp";
public static final String CREATE_USER_TABLE = "CREATE TABLE
lastname TEXT, username TEXT, password TEXT, email TEXT);";
LogIn login = new LogIn();
public DatabaseHelper(Context context, String name, CursorFactory
factory,int version)
super(context, DB_name, factory,DB_version);
// TODO Auto-generated constructor stub

public void onCreate(SQLiteDatabase db)

Toast.makeText(login.getApplicationContext(),"In Helper
onCreate()", Toast.LENGTH_SHORT).show();
// Create the table
db.execSQL("DROP TABLE IF EXISTS tbl_users");


public void onUpgrade(SQLiteDatabase db, int oldVersion, int
newVersion) {
// Housekeeping here.
// Implement how "move" your application data during an
upgrade of
schema versions
// There is no ALTER TABLE command in SQLite, so this
// CREATING a new table, moving data if possible, or
deleting the
old data and starting fresh
// Your call.
//db.execSQL("DROP TABLE IF EXISTS tbl_users");

public void onOpen(SQLiteDatabase db) {

and the class extending the activity is as follows

//import android.R.array;

Other Threads

1. anyway to have sub-directories in the res/drawable folder?

Is there anyway to have sub-directories in the res/drawable folder?
Right now if I add one, it is not recognized.
However if I put all my png files right into drawable, I can see them.


2. overlay hardware interface and surfaceflinger interaction

For overlay interface, the hardware driver is responsible for scaling,
rotation, etc. SurfaceFlinger just leaves a whole in the 2D composited
frame (black pixels with alpha = 0) to allow overlay surface to show
through the 2D surfaces.

To be clear, this means that the video overlay is behind the 2D
overlay. I believe there are provisions for chroma-key if the overlay
doesn't support an alpha channel.

Hi It appears that I can't reply to the discussion above previously
called 'About the libhardware and overlay hardware interface.'  From
the discussion it appears that a video overlay is displayed behind the
sufaceflinger's composited frame.  When using overlays, the discussion
states that the surfaceflinger leaves a hole with alpha=0 and pixels =
black, but the discussion it also implies that an overlay may have an
alpha channel.

If the surfaceflinger leaves a hole, then what use is the overlay
alpha because there will be no colors to multiply.  Surely the
surfaceflinger does not always leave a hole? and can have color pixels
so that the surfaceflinger's composted frame can be alpha blended with
an overlay frame using hardware?

If this is the case can a composted frame have an alpha value so that
the hardware knows how to multiply the foreground surface with the
background video overlay? or does the overlay always have to have the



3. Can OpenCore record a video and send it by RTP

4. Join the Android Developer Group on Linkedin!

5. Does Camera API really works ?

6. XMLHttpRequest

7. List in Gallery