Unfortunately app has stopped
<p>I am new to android programming. I am getting error "unfortunately app has stopped when running an app, to create database and retrieve the data. Here is the code:</p>

<pre><code>package com.employee.database;

import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.SQLException;
import android.content.Context;
import android.content.ContentValues;
import android.util.Log;
import android.database.Cursor;


public class DBAdapter {
    public static final String KEY_ROWID="_id";
    public static final String KEY_NAME="name";
    public static final String KEY_DEPT="dept";
    public static final String DATABASE_NAME="employee";
    public static final String DATABASE_TABLE="details";
    public static final String TAG="DBAdapter";
    public static final int DATABASE_VERSION=1;

    public static final String DATABASE_CREATE="create table details(_id integer primary key autoincrement,"
            +"name text not null, dept text not null,);";
    private final Context context;
    private SQLiteDatabase db;
    private DatabaseHelper DBHelper;

    public DBAdapter(Context ctx){
        this.context=ctx;
        DBHelper = new DatabaseHelper(context);
    }
    public class DatabaseHelper extends SQLiteOpenHelper{
        DatabaseHelper(Context context)
        {
            super(context, DATABASE_NAME,null,DATABASE_VERSION);
        }
        @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL(DATABASE_CREATE);
        }
        @Override
        public void onUpgrade(SQLiteDatabase db, int oldversion, int newversion){
            Log.w(TAG,"Upgrading database from"+oldversion+"to"+newversion+"will delete the table");
            db.execSQL("Drop table if exists details");
            onCreate(db);
        }
    }
       public DBAdapter open() throws SQLException {
             db=DBHelper.getWritableDatabase();
             return this;
             }
public void close(){
 db.close();    
 }
public long insertTitle(String name, String dept){
    ContentValues initialvalues=new ContentValues();
    initialvalues.put(KEY_NAME,name);
    initialvalues.put(KEY_DEPT,dept);
    return db.insert(DATABASE_TABLE, null, initialvalues);
}
public Cursor getAllTitles(){
    return db.query(DATABASE_TABLE, new String[]{
            KEY_ROWID,
            KEY_NAME,
            KEY_DEPT},
            null,
            null,
            null,
            null,
            null);

    }


public boolean updateTitle(long rowId, 
String name, String dept) 
{
    ContentValues args = new ContentValues();
    args.put(KEY_NAME, name);
    args.put(KEY_DEPT, dept);
    return db.update(DATABASE_TABLE, args, 
                     KEY_ROWID + "=" + rowId, null) &gt; 0;
}
}




package com.employee.database;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
import android.database.Cursor;


public class EmployeeActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        DBAdapter db = new DBAdapter(this);

        db.open();
        long id;
        id=db.insertTitle("Anu","Sales");
        id=db.insertTitle("Balu","Purchase");
        id=db.insertTitle("priya","HR");
        db.close();
        db.open();
        Cursor c = db.getAllTitles();
        if (c.moveToFirst())
        {
        do {
        DisplayTitle(c);
        } while (c.moveToNext());
        }
        db.close();
    }

    private void DisplayTitle(Cursor c) {
        // TODO Auto-generated method stub
        Toast.makeText(this,
                "id" + c.getString(0) + "\n"+
        "name" + c.getString(1) + "\n"+
        "dept" + c.getString(2) + "\n",
        Toast.LENGTH_LONG).show();
}
}
</code></pre>

<p>What is the mistake in the code.
Can somebody help me. Thank you.</p>
