打开 android 服务器中数据库连接的问题

我需要从服务器中调用一个方法来打开内部android数据库的连接,使用的下面的代码:

 public class myService extends Service{
    public void setDB(DB_DatabaseManager db){
        dbManager = db;
    }
    public DB_DatabaseManager dbManager;
    private Timer timer; 
    public IBinder onBind(Intent intent){
        return null;
    }
    public void onCreate(){
        super.onCreate();
        Log.i("my attempt","service activated");
        TimerTask task = new TimerTask(){
            public void run(){
                Log.i("my attempt","ANDROID SERVICE RUNNING!");
                dbManager.open(); // <--this statement generates error!
                                // --- in this section I start the communication with database

               }
        };
        timer = new Timer();
        timer.schedule(task, 0, 20000);
    }
   public void onDestroy(){
        super.onDestroy();
        timer.cancel();
        timer = null;
        Log.i("my attampt", "service stopped");
    }

open() 定义为:

 SQLiteDatabase mDb=mDbHelper.getWritableDatabase();

为了调用服务器,我使用:

    myService serv = new myService();
    serv.setDB(dbManager); 
    startService(new Intent(this,myService.class));

如果我删除dbManager.open(); 行,能正常运行,但是dbManager.open()方法在我代码的其它部分都能运行。但是在下面的情形中在logcat中获得下面的错误:

   08-06 23:44:32.287: E/AndroidRuntime(1115): FATAL EXCEPTION: Timer-0
   08-06 23:44:32.287: E/AndroidRuntime(1115): java.lang.NullPointerException
   08-06 23:44:32.287: E/AndroidRuntime(1115):  at host.framework.myService$1.run(myService.java:49)
   08-06 23:44:32.287: E/AndroidRuntime(1115):  at java.util.Timer$TimerImpl.run(Timer.java:284)

你先判断下dbManager是不是为null,你set了没