mercredi 7 janvier 2015

How to delete one marker from SQlite database?

I want to delete one marker from my SQLite database but when deleting the marker and returning to the map all the markers added are gone, and not sure why its doing that.


Here is my code to delete the marker:



public void onClick(DialogInterface arg0, int arg1) {
marker.remove();
LocationDeleteTask deleteTask = new LocationDeleteTask();
deleteTask.execute();


Then in my LocationDeleteTask method:



private class LocationDeleteTask extends AsyncTask<Void, Void, Void>{
@Override
protected Void doInBackground(Void... params) {
getContentResolver().delete(LocationsContentProvider.CONTENT_URI, null, null);
return null;


And (not sure if this will help) in my LocationsDataBase class:



public static final String FIELD_ROW_ID = "_id";
public static final String FIELD_LAT = "lat";
public static final String FIELD_LNG = "lng";
public static final String FIELD_ZOOM = "zom";
....
@Override
public void onCreate(SQLiteDatabase db) {
String sql = "create table " + DATABASE_TABLE + " ( " +
FIELD_ROW_ID + " integer primary key autoincrement , " +
FIELD_LNG + " double , " +
FIELD_LAT + " double , " +
FIELD_ZOOM + " text " +
" ) ";


Can anyone please help?


Aucun commentaire:

Enregistrer un commentaire