开发者

Show marker/geopoint with existing sqlite database

开发者 https://www.devze.com 2023-03-24 06:51 出处:网络
Anyone, please help me.. When i try to add location by long and lat on the source code, it\'s work. But

Anyone, please help me..

When i try to add location by long and lat on the source code, it's work.

But

when i tried to add location by existing database, i got force close.

here my source code :

private void initLokasi() {
    SQLiteDatabase db;
    db = openOrCreateDatabase(
        "imsyakiyah.db"
        , SQL开发者_开发百科iteDatabase.CREATE_IF_NECESSARY
        , null
        );
    db.setVersion(1);
    db.setLocale(Locale.getDefault());
    db.setLockingEnabled(true);

    Cursor cur = db.query("masjidmap", 
            null, null, null, null, null, null);
    cur.moveToFirst();
    while (cur.isAfterLast() == false) {
            String nama_masjid = cur.getString(1);
            int latitude = cur.getColumnIndex("latitude");
            int longitude = cur.getColumnIndex("longitude");
            list_lokasi.add(new Lokasi(longitude,latitude, 1,nama_masjid));
        cur.moveToNext();
    }
    cur.close();
}

What should i do?

Thanks


REPLACE

int latitude = cur.getColumnIndex("latitude");
int longitude = cur.getColumnIndex("longitude");

WITH

int latitude = cur.getInt(cur.getColumnIndex("latitude"));
int longitude = cur.getInt(cur.getColumnIndex("longitude"));
0

精彩评论

暂无评论...
验证码 换一张
取 消