AesculusMaximus AesculusMaximus - 2 months ago 5x
Android Question

Android database handler with imageview

I have created an activity that uses a canvas on which I can draw.

Within the activity, I need to retrieve data from a table that I have created elsewhere.

In other activities, I have used the database handler below and it works fine.

In this it does not, I think because I have extended imageview (required for the canvas) rather than extending Activity.

Thank you in advance for any help....

Here is my code:

public class examplecanvas extends ImageView {

float xPos, yPos;
private PointF point;
private Paint paint = new Paint();

public examplecanvas(Context context) {

public examplecanvas(Context context, AttributeSet attrs) {
super(context, attrs);

public examplecanvas(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);

public boolean onTouchEvent(@NonNull MotionEvent event) {
float x = event.getX();
float y = event.getY();


return true;

protected void onDraw(@NonNull Canvas canvas) {
if (point != null) {
canvas.drawCircle(point.x, point.y, 100, paint);;

public void getmydata() {

String parenta = "parent"

myDBhandler1 dbHandler;
dbHandler = new myDBhandler1(examplecanvas.this, null, null, 1); <<<<HERE IS THE ERROR


...and this is the error I get:

error message


Your database handler requires a context, so you could pass

new myDbHandler1(getContext(), ...);