At first my sendData method is working but when I call it from another activity it has 'not attached to a context.' error.

When I opened it looks work, but after i delete some data it wasn't work.

Here is my code.

DeleteDialog.java

```
public class DeleteDialog extends android.support.v4.app.DialogFragment {
private Context mContext;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.activity_delete_dialog, container, false);

    mContext=this.getContext();

...

ok_btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(editText.getText().toString().equals("")){
                Toast.makeText(getContext(), "과목명을 입력해 주세요", Toast.LENGTH_SHORT).show();

            }else{

                dbHelper = new DBHelper(mContext);
                db = dbHelper.getWritableDatabase();
                dbHelper.deleteColum(editText.getText().toString());
                timeTableFragment.sendData(mContext);
                getDialog().dismiss();
            }

        }
    });

```

TimeTableFragment.java

```
public class TimeTableFragment extends Fragment {
private Context mContext;

public void sendData(Context context) { //get data and draw to layout
    dbHelper = new DBHelper(context);
    db = dbHelper.getWritableDatabase();
    dbHelper.onCreate(db);
    String date = "", start = "", end = "", title = "", color = "";

    ArrayList<SubjectItem> timetable_data;
    timetable_data = dbHelper.getDataTimetable(); //get data from sql
    SimpleDateFormat sf = new SimpleDateFormat("HHmm");

    int resID = 0;
    int mok;
    Date a, b;
    long diff, min;
    View view = getView();

    for (int i = 0; i < timetable_data.size(); i++) {  // draw to layout
        date = timetable_data.get(i).getSub_date();
        start = timetable_data.get(i).getSub_start();
        end = timetable_data.get(i).getSub_end();
        title = timetable_data.get(i).getSub_title();
        color = timetable_data.get(i).getSub_color();

        if (date.substring(0, 2).equals("Th")) {
            date = "h";
            Log.d("ㄹㄹ","목요일 : " +date);
        }
        date = date.toLowerCase().substring(0, 1);
        Log.d("ㄹㄹ","바깥의 데이터 : " +date);
        start = start.replace(":", "");
        end = end.replace(":", "");

        try {
            a = sf.parse(start);
            b = sf.parse(end);
            diff = b.getTime() - a.getTime();
            min = (diff / (1000 * 60));
            mok = (int) min / 30;

            Log.d(TAG,"title " +title + " start :  " + start +","+ a.getTime()+ " / end : " +  end+","+b.getTime() +   "   date : " + date);

            for (int k = 0; k < mok; k++) {

                if (mok != 1) {

                    if (end.substring(2, 4).equals("30")) {
                        end = Integer.toString(Integer.parseInt(end) - 30);
                        if (end.length() == 3) end = "0" + end;
                        Log.d(TAG, " 그리기 title :  " +title );
                        //Log.d(TAG , "콘텍스트 : " + getContext().getPackageName());
         Error ->       resID = getResources().getIdentifier(date + end, "id", getContext().getPackageName());
                        TextView textView = (TextView) view.findViewById(resID);
                        textView.setText(title);
                        paintTimetable(textView,color);

                    } else {
                        end = Integer.toString(Integer.parseInt(end) - 70);
                        if (end.length() == 3) end = "0" + end;
                        Log.d("Contxet " , "콘텍스트 : " + getContext().getPackageName());
                        resID = getResources().getIdentifier(date + end, "id", getContext().getPackageName());
                        TextView textView = (TextView) view.findViewById(resID);
                        textView.setText(title);
                        paintTimetable(textView,color);
                        Log.d(TAG, " 그리기 title :  "  +title);
                    }
                } else {
                    Log.d("Contxet " , "콘텍스트 : " + getContext().getPackageName());
                    resID = getResources().getIdentifier(date + start, "id", getContext().getPackageName());
                    TextView textView = (TextView) view.findViewById(resID);
                    textView.setText(title);
                    paintTimetable(textView,color);

                }
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }

    }
}

@Override
public void onAttach(Context context) {
    super.onAttach(context);

    try {

        mContext=getContext();
    } catch (ClassCastException e) {
        Log.d(TAG, "Exception" + e.getMessage());
    }
}

```

DBHelper.java

```
public class DBHelper extends SQLiteOpenHelper {

public DBHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);

}

... 

public void deleteColum(String name)
{
    String DELETE = "DELETE FROM " + TABLE_TIMETABLE + " WHERE " + KEY_TITLE + "='" + name + "'";

    SQLiteDatabase db = this.getWritableDatabase();
    db.execSQL(DELETE);
    Log.d("dd", "sql deleted  :  " + name);

}

```

And Error message :

```
Fragment TimeTableFragment{f4aa844} not attached to a context.

```

In DB Insert, Delete are perfectly works but after call sendData method in DeleteDialog occurred 'not attached to a context'.

What context should I send and receive?