Instead of "this", pass the context in the onReceive()

DBAdapter db = new DBAdapter(context);

Nithin

On Dec 22, 8:58 pm, shalon <[email protected]> wrote:
> Hi all
>
> I am trying to build an application where i can store my incoming sms
> into a database.
>
> I have DBAdapter class which does database connectivity with following
> constructor
>
> public DBAdapter(Context ctx)
>   {
>       this.context = ctx;
>       DBHelp = new DatabaseHelper(context);
>   }
>
> When I try to create an object of DBAdapter class in my SMSReceiver
> class i get the following error:
>
> "The constructor DBAdapter(SMSReciever) is undefined"
>
> Here is the SMSReceiver class code
>
> public class SMSReciever extends BroadcastReceiver
> {
>
>     @Override
>     public void onReceive(Context context,Intent intent)
>     {
>
>         DBAdapter db = new DBAdapter(this); // "this is where i get
> error"
>
>      // ---get the SMS message passed in---
>     }
>
> }
>
> please help me with this issue.
>
> Thank you in advance

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to