我收到以下错误。请告诉我如何删除此错误。由于我的应用程序中的Toast,我收到此错误。如果我删除这个吐司一切正常。请帮助我。
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
我正在测试htc1x。
以下是我使用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);
}
答案 0 :(得分:1)
请勿使用getBaseContext()
。只需使用this
代替。
如果您尝试使用Toast
显示Service
,请使用getApplicationContext()
。
答案 1 :(得分:0)
嘿,你应该使用这段代码:
Toast.makeText(getApplicationContext(), "already exist",Toast.LENGTH_SHORT).show();