lundi 5 janvier 2015

get the context from an non-activity class into a non-activity

I'd like to get access from my database which is the DBAdapter.class (not an activity) into another non-activity class that randoms data RandomData.class


my sample code was like:



DBAdapter getAvailRandom=new DBAdapter(getApplicationContext());
getAvailRandom.open();
...
....
...

getAvailRandom.close();


getApplicationContext() is always undefined


I tried getActivity.getApplicationContext() and Activity.this , but still not working


Aucun commentaire:

Enregistrer un commentaire