Advertisement
Guest User

123

a guest
Aug 28th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.57 KB | None | 0 0
  1.     public class Database {
  2.        
  3.         static ProgressDialog progresso;
  4.         private DbHelper DBHelper;
  5.         private final Context Context;
  6.         private SQLiteDatabase BaseDados;
  7.         static Context ctx;
  8.  
  9.         private static class DbHelper extends SQLiteOpenHelper {
  10.            
  11.            
  12.             public DbHelper(Context context) {
  13.                 super(context, BD_NAME, null, BD_VERSION);
  14.                 ctx = context;
  15.                 // TODO Auto-generated method stub
  16.             }
  17.  
  18.             @Override
  19.             public void onCreate(SQLiteDatabase db) {
  20.                
  21.                 Database x = new Database(ctx);
  22.                 Database.loadDB load = x.new loadDB();
  23.                 load.execute();
  24.  
  25.             }
  26.  
  27.             @Override
  28.             public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVesion) {
  29.             }
  30.  
  31.         }
  32.  
  33.         public Database(Context c) {
  34.             Context = c;
  35.         }
  36.  
  37.         public Database open() throws SQLException {
  38.             DBHelper = new DbHelper(Context);
  39.             BaseDados = DBHelper.getWritableDatabase();
  40.             return this;
  41.         }
  42.  
  43.         public void close() {
  44.             DBHelper.close();
  45.         }
  46.     }
  47.        
  48.         public class loadDB extends AsyncTask<Void, Void, Integer> {
  49.  
  50.             @Override
  51.             protected void onPreExecute() {
  52.                 // TODO Auto-generated method stub
  53.                 super.onPreExecute();
  54.                 System.out.println("gets here");
  55.                 progresso = ProgressDialog.show(ctx, ctx.getString(R.string.driProgressTitle), ctx.getString(R.string.driProgressMessage) );
  56.             }
  57.  
  58.             @Override
  59.             protected Integer doInBackground(Void... params) {
  60.                 return 1;
  61.             }
  62.  
  63.             @Override
  64.             protected void onPostExecute(Integer result) {
  65.                 System.out.println("and gets here");
  66.                 progresso.dismiss();
  67.                 super.onPostExecute(result);
  68.             }
  69.         }
  70.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement