我正在尝试使用insert方法插入数据。在插入它们之前,我想检查数据是否已经存在于数据库中。当我运行应用程序时,我看到了错误:
11-03 19:26:37.871: E/ActivityThread(20976): Failed to find provider info for com.app.mapa.MCProvider
11-03 19:26:37.871: W/dalvikvm(20976): threadid=1: thread exiting with uncaught exception (group=0x40da61f8)
我的代码:
public class Insertarlugar extends Activity {
protected static final int RESULT_LOAD_IMAGE = 1;
ImageView imgfto;
Button gboton;
private static int CAPTURA_FOTO = 2;
private static int SELECT_FOTO = 1;
EditText titlugar;
EditText desclugar;
String tlugar;
String dlugar;
double lat;
double lgt;
String sfoto;
public void BotonListener()
{
gboton = (Button) findViewById(R.id.guardar);
gboton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
titlugar = (EditText) findViewById(R.id.edit_titulo_lugar);
tlugar = titlugar.getText().toString();
desclugar = (EditText) findViewById(R.id.edit_descripcion_lugar);
dlugar = desclugar.getText().toString();
Bundle parametros = getIntent().getExtras();
lat = parametros.getDouble("latitud");
lgt = parametros.getDouble("longitud");
Uri ufoto = Uri.parse("android.resource://" + getPackageName() + "/" +
R.drawable.camara1);
sfoto = ufoto.toString();
boolean igual = iguales();
if(!igual)
{
ContentValues valores = new ContentValues();
valores.put("nombre", tlugar);
valores.put("descripcion", dlugar);
valores.put("latitud", lat);
valores.put("longitud", lgt);
valores.put("foto", sfoto);
}
}
});
}
The error is in this function:
public boolean iguales()
{
boolean ig = false;
Uri urititl = Uri.parse("content://com.app.mapa.MCProvider /" + Bdoh.T_NOMBRE);
Cursor c = getContentResolver().query(urititl,null,null,null,null);
if(c.moveToFirst()) //the error is pointed in this line
{
if((titlugar.equals(c.getString(1))) && (lat == c.getDouble(2)) &&
(lgt == c.getDouble(3)))
ig = true;
else ig = false;
}
return ig;
}
以下是logcat的其余部分:
11-03 19:26:37.891: E/AndroidRuntime(20976): FATAL EXCEPTION: main
11-03 19:26:37.891: E/AndroidRuntime(20976): java.lang.NullPointerException
11-03 19:26:37.891: E/AndroidRuntime(20976): at com.app.mapa.Insertarlugar.iguales(Insertarlugar.java:231)
11-03 19:26:37.891: E/AndroidRuntime(20976): at com.app.mapa.Insertarlugar$2.onClick(Insertarlugar.java:199)
11-03 19:26:37.891: E/AndroidRuntime(20976): at android.view.View.performClick(View.java:3521)
11-03 19:26:37.891: E/AndroidRuntime(20976): at android.view.View$PerformClick.run(View.java:14185)
11-03 19:26:37.891: E/AndroidRuntime(20976): at android.os.Handler.handleCallback(Handler.java:605)
11-03 19:26:37.891: E/AndroidRuntime(20976): at android.os.Handler.dispatchMessage(Handler.java:92)
11-03 19:26:37.891: E/AndroidRuntime(20976): at android.os.Looper.loop(Looper.java:137)
11-03 19:26:37.891: E/AndroidRuntime(20976): at android.app.ActivityThread.main(ActivityThread.java:4464)
11-03 19:26:37.891: E/AndroidRuntime(20976): at java.lang.reflect.Method.invokeNative(Native Method)
11-03 19:26:37.891: E/AndroidRuntime(20976): at java.lang.reflect.Method.invoke(Method.java:511)
11-03 19:26:37.891: E/AndroidRuntime(20976): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:822)
11-03 19:26:37.891: E/AndroidRuntime(20976): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:589)
11-03 19:26:37.891: E/AndroidRuntime(20976): at dalvik.system.NativeStart.main(Native Method)
11-03 19:26:40.991: E/Adreno200-ES20(21174): <qgl2DrvAPI_glUseProgram:1318>: **** 21174: glUseProgram(6)
为什么找不到MCProvider?
感谢。