Why can I not pass this as Context in following code?
I am getting error
The constructor DataManager(new View.OnClickListener(){}) is undefined
I am new to android programming, so sorry if question is weird!!
Any help would be great.
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Log.d("vkx", "clk insert");
String qq="insert into users(id,name,password) values ('6','usrs','passs')";
DataManager dm=new DataManager(this);
dm.SqliteExecutenonquery(qq);
Log.d("vkx", "clk insert done");
}
});
I have my DataManger class
public DataManager(Context cont) {
super(cont, DBname, null, DBver);
}
....
So what you are doing is when instantiating DataManager, You are not passing a context as a paramater but actually your instance of OnClickListener.
YOUR_CLASS_NAME should be the Activity class name. ie
Give this a try and let me know how it goes