null pointer exception at db insert
<pre><code>package com.omkarsoft.ImagePortofolio;

import java.util.ArrayList;

import com.omkarsoft.ImagePortofolio.dataBaseHelper;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class sqlQueries {
     dataBaseHelper database;
     SQLiteDatabase db ;
     UrlList urllist ;

     public sqlQueries( dataBaseHelper dbh , SQLiteDatabase db  )
     {
         database = dbh;
         this.db = db;
     }

      public sqlQueries() {
          System.out.println("no are sqlqueries constructor");
    }

    public void insertIntoCompanyTable( String companyname  ) {

                 db = database.getWritableDatabase(); // this works fine here
            ContentValues values = new ContentValues();
            values.put(dataBaseHelper.COMPANY_NAME, companyname);
            System.out.println(values);
            db.insert(dataBaseHelper.COMPANY_LIST, null, values);
          }

    public int getCompanyID( String companyName)
    {
        int id = 0 ;
        Cursor c = null;

            try {
            db = database.getReadableDatabase(); // this works fine here
                String query = "SELECT company_id FROM company_list WHERE company_name = '"+ companyName +"'";
                c = db.rawQuery(query,null);
            } catch (Exception e) {
                System.out.println("In getCompanyID : " +e);
            }

        if (c != null ) {
            if  (c.moveToFirst()) {
                id = c.getInt(c.getColumnIndex("company_id"));
            } 
        }
        return id;
    }

    public int getCompanies( String comp) {
        int id = 0;
        Cursor c = null;
        ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;();

        try {
            db = database.getReadableDatabase(); // this works fine here
            String query = "SELECT * FROM company_list ";
            c = db.rawQuery(query, null);
        } catch (Exception e) {
            System.out.println(e);
        }

            if (c != null) {

                if (c.getCount() == 0)
                    id = 1;
                else {
                    if (c.moveToFirst()) {

                        do {
                            String name = c.getString(c.getColumnIndex("company_name"));
                            names.add(name);
                        } while (c.moveToNext());
                    }

                    if( names.contains(comp))
                        id = 0;
                        else
                        id = 1 ;
                }
            }

        return id;
    }

      public void insertIntoImageTable( int companyid , String productname , String productdesc , byte[] bmp )
      {
            try
            {
                        db = database.getWritableDatabase(); // blows here i get a NPE
                ContentValues values = new ContentValues();
                values.put(dataBaseHelper.COMPANY_ID, companyid);           
                values.put(dataBaseHelper.PRODUCT_NAME, productname);
                values.put(dataBaseHelper.PRODUCT_DESCRIPTION, productdesc);
                values.put(dataBaseHelper.PRODUCT_IMAGE, bmp);
                System.out.println(values);
                db.insertOrThrow(dataBaseHelper.IMAGE_DATA, null, values);
                System.out.println(values);
            }
            catch( Exception e)
            {
                e.printStackTrace();
            }
      }
}
</code></pre>
