开发者

Uncaught handler: thread main exiting due to uncaught exception

I am 开发者_如何学Cusing this tutorial here and when I add this section of code directly into my OnCreate class I get the above error

DataBaseHelper myDbHelper = new DataBaseHelper(null);
myDbHelper = new DataBaseHelper(this);

try {
    myDbHelper.createDataBase();
} catch (IOException ioe) {
    throw new Error("Unable to create database");
}

try {
    myDbHelper.openDataBase();
} catch(SQLException sqle){
    throw sqle;
}

I am still pretty new so any help and pointing in the right direction is most appreciated.


You have to pass DataBaseHelper a valid Context. You'll probably want to pass it the main Activity (or this if it is in the Activity).


To get more information about the exception, try "chaining" the thrown Error with the caught IOException:

catch (IOException ioe) {
    throw new Error("Unable to create database", ioe);
}

That should show you the SQLException that is being thrown.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜