Tuesday, March 8, 2011

[android-developers] Re: how to use normal class object as context?

Do with the same thing with your "normal" class as you are with your Database class: give it an instance of a Context to work with.

Doug

On Monday, March 7, 2011 3:38:30 AM UTC-8, Hitendrasinh Gohil wrote:
hi,

i have one database class.in which i have
public Database(Context ctx)
{
context = ctx;
DBHelper = new DatabaseHelper(context);
}
where DatabaseHelper is a static class.

Now my problem is that if i call it from activity class than there is
no problem.
but i have one normal java class.
like public class xyz
{
}

how to instantiate database class from this class.
if i do like db = new Database(this); it gives me error.
so how can i achieve this?
thankx

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment