mardi 3 février 2015

What is error here on my codes?

Everytime I run it in my phone, the error is "Android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0-s". Can you help me to fix it? :/


here is query..



public Cursor find(String data)
{
SQLiteDatabase db = this.getReadableDatabase();

Cursor res = db.query(MYDATABASE_TABLE, new String[] { KEY_ID,
CONTENT_POSITION}, CONTENT_POSITION + "=?",
new String[] { }, null, null, null, null);

return res;
}

and my search codes..

public void onClick01(View arg0)
{
try
{
map_search = (EditText) findViewById(R.id.content1);
String input = map_search.getText().toString();
// TODO Auto-generated method stub
Log.d("data input :", input);
res = mySQLiteAdapter.find(input);
String result = res.getString(0);
if(!res.isClosed())
{
res.close();
}

Log.d("data input :",result);
double lat=0,lng=0;
int rslt = Integer.parseInt(result);

switch(rslt)
{
case 3:
lat = 14.669645;
lng = 121.003384;
break;
}
LatLng php4 = new LatLng(lat, lng);
googleMap.setMyLocationEnabled(true);
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(php4, 13));
CameraUpdate center= CameraUpdateFactory.newLatLng(new LatLng(14.669645, 121.003384));
CameraUpdate zoom=CameraUpdateFactory.zoomTo(18);

googleMap.moveCamera(center);
googleMap.animateCamera(zoom);
googleMap.addMarker(new MarkerOptions()
.title("This is your deceased location.")
.snippet("try")
.position(php4));


map_btn.setText("");

}

Aucun commentaire:

Enregistrer un commentaire