public class Database {
static ProgressDialog progresso;
private DbHelper DBHelper;
private final Context Context;
private SQLiteDatabase BaseDados;
static Context ctx;
private static class DbHelper extends SQLiteOpenHelper {
public DbHelper(Context context) {
super(context, BD_NAME, null, BD_VERSION);
ctx = context;
// TODO Auto-generated method stub
}
@Override
public void onCreate(SQLiteDatabase db) {
Database x = new Database(ctx);
Database.loadDB load = x.new loadDB();
load.execute();
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVesion) {
}
}
public Database(Context c) {
Context = c;
}
public Database open() throws SQLException {
DBHelper = new DbHelper(Context);
BaseDados = DBHelper.getWritableDatabase();
return this;
}
public void close() {
DBHelper.close();
}
}
public class loadDB extends AsyncTask<Void, Void, Integer> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
System.out.println("gets here");
progresso = ProgressDialog.show(ctx, ctx.getString(R.string.driProgressTitle), ctx.getString(R.string.driProgressMessage) );
}
@Override
protected Integer doInBackground(Void... params) {
return 1;
}
@Override
protected void onPostExecute(Integer result) {
System.out.println("and gets here");
progresso.dismiss();
super.onPostExecute(result);
}
}
}