0

I am getting the below error.please tell me how to remove this error.I am getting this error because of Toast in my app. if I remove this toast everything works correctly.please help me.

logcat:

08-17 20:12:23.753: E/(7381): file /data/data/com.nvidia.NvCPLSvc/files/driverlist.txt:  not found!
08-17 20:12:23.753: I/(7381): Attempting to load EGL implementation /system/lib//egl/libEGL_tegra_impl
08-17 20:12:23.758: I/(7381): Loaded EGL implementation /system/lib//egl/libEGL_tegra_impl
08-17 20:12:23.793: I/(7381): Loading GLESv2 implementation /system/lib//egl/libGLESv2_tegra_impl

I am testing on htc1x.

Here is the complete method in which I am using Toast

public long putvalues(String event_name,String event_date,String event_time,String event_location){


    String anArray[] = new String[] {Column_Id,name,date,time,location};
    Log.d("in is duplicate","ere");
    Cursor c = ourSQLiteDatabase.query(Table_Name, anArray,name+" =?"+" AND "+date+" =?"+" AND "+time+" =?"+" AND "+location+" =?" ,
            new String[] {event_name,event_date,event_time,event_location}, null, null, null);

    if(c != null){
        Log.d("in if","in if");
        Toast.makeText(getBaseContext(), "already exist",Toast.LENGTH_SHORT).show();

    } 
ContentValues cv = new ContentValues();
    cv.put(name, event_name);
    cv.put(date, event_date);
    cv.put(time, event_time);
    cv.put(location, event_location);
    Log.d("in reminder", "put values1");
    return ourSQLiteDatabase.insert(Table_Name, null, cv);  
}
Geetika
  • 316
  • 9
  • 23

2 Answers2

1

Do not use getBaseContext(). Just use this instead.

If you're trying to show a Toast from a Service, use getApplicationContext().

Michael
  • 53,859
  • 22
  • 133
  • 139
0

Hey u should use this code:

Toast.makeText(getApplicationContext(), "already exist",Toast.LENGTH_SHORT).show();
Prakhar
  • 2,270
  • 19
  • 26
  • no i m not using any thread.I just created a database and now i want to show a toast when user tries to save same data. – Geetika Aug 17 '13 at 15:34