Here is the code for DBHelper.java. The ProgressDialog code that is in bold is the one that causes the FC. I know this because if I comment it out then everything works fine and my db tables get created. From what I can tell the error is, "system services not available to activities before oncreate". No idea what is going on and I've used the exact same ProgressDialog code in my GolfCaddie.java file and it works fine there.
package com.dtwconsulting.golfcaddietrial;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import android.util.Log;
public class DBHelper extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
*bunch of static constants are defined, but removed for readability.
* private SQLiteDatabase db;
private DatabaseHelper dbHelper;
private final Context dbCtx;
private static final String TAG = "DBHelper";
private class DatabaseHelper extends SQLiteOpenHelper {
DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
// If we get to this point then it means that this is the
first time the app
// has been run and we need to create the Golf Caddie DB.
*ProgressDialog dialog = ProgressDialog.show(DBHelper.this, "",
"New install...setting up database",true);*
String[] sqlStatements = new String[]{SQL1, SQL2, SQL3,
SQL4, SQL5, SQL6, SQL7, SQL8, SQL9, SQL10, SQL11
, SQL12, SQL13, SQL14, SQL15, SQL16, SQL17, SQL18,
SQL19, SQL20, SQL21, SQL22, SQL23, SQL24, SQL25, SQL26
, SQL27, SQL28, SQL29, SQL30, SQL31, SQL32, SQL33,
SQL34, SQL35, SQL36, SQL37, SQL38, SQL39, SQL40, SQL41
, SQL42, SQL43};
for(String sql : sqlStatements){
db.execSQL(sql);
}
dialog.dismiss();
}
}
public DBHelper(Context ctx) {
this.dbCtx = ctx;
}
public DBHelper open() throws SQLException {
dbHelper = new DatabaseHelper(dbCtx);
db = dbHelper.getWritableDatabase();
return this;
}
public void close() {
dbHelper.close();
}
}
--
------------------------------------------------------------------------
David Williams
Check out our WebOS mobile phone app for the Palm Pre and Pixi:
<http://www.dtw-consulting.com/GolfCaddie> Golf Caddie
<http://www.dtw-consulting.com/GolfCaddie> | Golf Caddie Forum
<http://www.dtw-consulting.com/GolfCaddie/forum> | Golf Caddie FAQ
<http://www.dtw-consulting.com/GolfCaddie/faq.html> 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
<<inline: GClogo.png>>

