Don't use getBaseContext(), just use the Context you have.

And if you are doing something from a background service, Service is-a
Context, so you can just use the service instance.

On Wed, Jan 28, 2009 at 7:26 PM, suhas gavas <[email protected]> wrote:

>
> try passing getBaseContext() in place of this
>
>
>
>
> On Wed, Jan 28, 2009 at 9:28 PM, Immy <[email protected]> wrote:
>
>>
>> Hi,
>>
>> Thanks for the reply..
>>
>> This is what I'm doing in all other classes, which happen to be
>> Activities...
>> But here,
>>
>> Database_mob mDbHelper = new Database_mob(this);
>>
>> generates an error which says Database_mob(*classname*) is undefined.
>>
>> Regards,
>> Immanuel
>>
>>
>>
>>
>> On Jan 28, 12:51 pm, suhas gavas <[email protected]> wrote:
>> > make object of the class in which u have to use the context .........
>> Then
>> > pass as parameter this to the class ............ And the class in which
>> u
>> > have to use conext should have constructor as parameter context in it
>> >
>> > e.g
>> >
>> > class activity extends Activity
>> > {
>> >      Viewclass myclass;
>> >       public oncreate()
>> >       {
>> >          myclass = new Viewclass (this);
>> >
>> >        }
>> >
>> > }
>> >
>> > -----------------------------------------------
>> >
>> > class Viewclass
>> > {
>> >     public Viewclass (Context context)
>> >    {
>> >     }
>> >
>> > }
>> >
>> > > On Wed, Jan 28, 2009 at 12:43 PM, Immy <[email protected]>
>> wrote:
>> >
>> > >> Hi,
>> >
>> > >> Can anyone tell me how to access context of a class which is not an
>> > >> activity?
>> >
>> > >> Thanks,
>> > >> Immanuel
>>
>>
>
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to