开发者

Want to retrieve SQlite data and set it to map markers[ForceClose]

开发者 https://www.devze.com 2023-03-30 03:38 出处:网络
I have an SQLite DB that\'s storing all coordinates + description to show them when taping on markers. I\'m using this code to retreive all descriptions:

I have an SQLite DB that's storing all coordinates + description to show them when taping on markers. I'm using this code to retreive all descriptions:

protected boolean onTap(int index) {
            db = openHelper.getWritableDatabase();
           String[] result_columns = new String[] {COL_DESCRI};
            Cursor cur = db.query(true, TABLE_COORD, result_columns,
             null, null, null, null, null, null);
             cur.moveToFirst();
             while (cur.isAfterLast() == false) {
                String description = cur.getString(cur.getColumnIndexOrThrow("Description"));

                AlertDialog.Builder dialog = new AlertDialog.Builder(Geo.this);
                dialog.setTitle("Infos.");
                dialog.setMessage(description);
                dialog.setPositiveButton("OK", new OnClickListener() {    
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                dialog.show();

                cur.moveToNext();
             }
             cur.close();
             db.close();

            return true;

However, i'm having a weird problem that indicates that i'm not having Description column and i'm pretty sure that i have it.

08-23 02:45:02.848: ERROR/AndroidRuntime(287): Uncaught handler: thread main exiting due to uncaught exception
08-23 02:45:02.890: ERROR/AndroidRuntime(287): android.database.sqlite.SQLiteException: no such column: Description: , while compiling: SELECT DISTINCT Description FROM table_coordonnées
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.database.sqlite.SQLiteProgram.native_compile(Native Method)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.database.sqlite.SQLiteProgram.compile(SQLiteProgram.java:110)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:49)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1220)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1107)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1065)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at carburant.android.com.Geo$ItemizedOverlayPerso.onTap(Geo.java:239)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at com.google.android.maps.ItemizedOverlay.onTap(ItemizedOverlay.java:453)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at com.google.android.maps.OverlayBundle.onTap(OverlayBundle.java:83)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at com.google.android.maps.MapView$1.onSingleTapUp(MapView.开发者_StackOverflow社区java:346)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.view.GestureDetector.onTouchEvent(GestureDetector.java:506)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at com.google.android.maps.MapView.onTouchEvent(MapView.java:628)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.view.View.dispatchTouchEvent(View.java:3709)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:852)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.os.Looper.loop(Looper.java:123)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at android.app.ActivityThread.main(ActivityThread.java:4363)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at java.lang.reflect.Method.invokeNative(Native Method)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at java.lang.reflect.Method.invoke(Method.java:521)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
08-23 02:45:02.890: ERROR/AndroidRuntime(287):     at dalvik.system.NativeStart.main(Native Method)

What could be the problem please? Thanks for helping.


Please check your create statements and queries. I would use lower case everywhere. In an edit you write coordoonnees and table_coordoonnees. Both don't match.

SQLites error messages are very helpful always. If SQLite tells you about a missing table or column this item is definetely missing or mis-spelled.


It looks like "no such column: Description" and so you have to check your database once and also you are going in a wrong direction.

You are fetching co-ordinates in onTap() method and after getting cursor you are fetching loop and in loop you have write a code for display dialog.

So your code will give you description of only last record.

You have to create array of description for all co-ordinates and then in onTap(int index) you have to get co-ordinates using index variable of onTap(int index) method

0

精彩评论

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

关注公众号