title: Issue with auto-population of markers on GoogleMap app in android studio
body: <p>I have been working on an app where a user can click on a location on a GoogleMap in android studio to add a marker at that location. It then prompts you with 3 buttons, one to dismiss, one to add a title and description, and one to add a photo. </p>
  
  <p>If I just press dismiss, the coordinates of the location I click on is automatically saved in the SQLite, but if I add a note and then confirm and return to the screen, the marker does not show up. It does not make sense because the locations are definitely saved to the database, but when I add the title or description or photo to the database and go back, it almost erases the coordinates from SQLite.</p>
  
  <p>The coordinates should be saved upon adding the marker, with this code </p>
  
  <pre><code>mydb = openOrCreateDatabase("locationmarkersqlite", Context.MODE_PRIVATE, null);
  
      Cursor cursor = mydb.rawQuery("select _id from locations where lat = '" + latiString + "' and lng = '" + lngiString + "'", null);
      if (cursor.moveToFirst()) {
          do {
              lastId = cursor.getString(0);//can be lastId = cursor.getString("_id");
  
          }
          while (cursor.moveToNext());
      }
  </code></pre>
  
  <p>The database is managed by this SQLiteOpenHelper</p>
  
  <pre><code>public class LocationsDB extends SQLiteOpenHelper{
  
      /** Database name */
      private static String DBNAME = "locationmarkersqlite";
  
      /** Version number of the database */
      private static int VERSION = 1;
  
      /** Field 1 of the table locations, which is the primary key */
      public static final String FIELD_ROW_ID = "_id";
  
      /** Field 2 of the table locations, stores the latitude */
      public static final String FIELD_LAT = "lat";
  
      /** Field 3 of the table locations, stores the longitude*/
      public static final String FIELD_LNG = "lng";
      /** Field 4 of the table locations, stores the zoom level of map*/
      public static final String FIELD_ZOOM = "zom";
      public static final String FIELD_TITLE = "title";
      public static final String FIELD_BODY = "body";
      public static final String FIELD_PHOTO = "photo";
  
  
  
      /** A constant, stores the the table name */
      private static final String DATABASE_TABLE = "locations";
  
      /** An instance variable for SQLiteDatabase */
      private SQLiteDatabase mDB;  
  
  
      /** Constructor */
      public LocationsDB(Context context) {
          super(context, DBNAME, null, VERSION);  
          this.mDB = getWritableDatabase();
      }
  
  
  
      @Override
      public void onCreate(SQLiteDatabase db) {
          String sql =    "create table " + DATABASE_TABLE + " ( " +
                              FIELD_ROW_ID + " integer primary key autoincrement , " +
                              FIELD_LNG + " text , " +
                              FIELD_LAT + " text , " +
                              FIELD_ZOOM + " text ," +
                              FIELD_TITLE + " text ," +
                              FIELD_BODY + " text ," +
                              FIELD_PHOTO + " text " +
                          " ) ";
  
          db.execSQL(sql);
  
      }
  
      /** Inserts a new location to the table locations */
      public long insert(ContentValues contentValues){
          long rowID = mDB.insert(DATABASE_TABLE, null, contentValues);
          return rowID;
  
      }   
  
      public int update(ContentValues contentValues,String contactID){
          int cnt = mDB.update(DATABASE_TABLE, contentValues, "_id=" + contactID, null);
          return cnt;
      }
  
  
      /** Deletes all locations from the table */
      public int del(){
          int cnt = mDB.delete(DATABASE_TABLE, null , null);      
          return cnt;
      }
  
      /** Returns all the locations from the table */
      public Cursor getAllLocations(){
          return mDB.query(DATABASE_TABLE, new String[] { FIELD_ROW_ID,  FIELD_LAT , FIELD_LNG, FIELD_ZOOM } , null, null, null, null, null);
      }
  
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  
      }
  
  }
  </code></pre>
  
  <p>Any ideas on what I should do? Everything else is in running order. </p>