Monday, March 14, 2011

Re: [android-developers] Creating SQLite DB

Did you try
this.getApplicationContext().openOrCreateDatabase(DATABASE_NAME, Context.MODE_PRIVATE, null);
?

W dniu 14.03.2011 01:46, David Williams pisze:
All,

I am trying to create an SQLite DB but for some reason it's not working.
My logic performs the following.

    db.openDatabase(GlobalVars.DATABASE_NAME, null, 0);

This simply tries to open my DB.  If the DB doesn't exist it will throw an exception, which I can check, but I would suspect that if the DB can't be opened it doesn't exist, therefore my assumption then is that this is a new install of my app and I need to create my DB.  So, in my exception I am doing the following:

    db.openOrCreateDatabase(GlobalVars.DATABASE_NAME, null);

I'd expect the above command to create the database regardless, but it isn't.  The exception I am getting for both of the above commands is: unable to open database file. I am surprised am I getting this in the second exception as I would expect it to create the DB.

DATABASE_NAME = "golfcaddie.db"

What am I doing wrong?


--

David Williams
Check out our WebOS mobile phone app for the Palm Pre and Pixi:
   Golf Caddie | Golf Caddie Forum | Golf Caddie FAQ by DTW-Consulting, Inc.


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment