开发者

Closing WordDBAdapter in onDestroy

I need to close my WordDBAdapter object in the onDestroy method in Android. Is one of these better than the other?

@Override
protected void onDestroy()
{
    super.onDestroy();

    if(dbWord instanceof WordDBAdapter)
    {
        dbWord.close();
    }
}

----- OR ------

@Override
protected void on开发者_如何学编程Destroy()
{
    super.onDestroy();

    if(dbWord != null)
    {
        dbWord.close();
    }
}

Thanks!


There is a problem in your code, whatever approach you use the ordering of statement should be as follow:

@Override
protected void onDestroy()
{
    if(dbWord != null)
    {
        dbWord.close();
    }
 super.onDestroy();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜