JavaWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JavaWorld@TW » Java ME、Google Android 平台與 JavaCard 討論區 » Android  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
作者 cursor關閉時機
uxa





發文: 441
積分: 6
於 2010-02-09 13:37 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
小弟在ListActivity中去query db,然後會把得到的資料傳給另一個Activity,在執行時都會發現

1
2
3
4
02-09 05:28:02.112: INFO/dalvikvm(714): Uncaught exception thrown by finalizer (will be discarded):
02-09 05:28:02.122: INFO/dalvikvm(714): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@435eea10 on rate that has not been deactivated or closed
02-09 05:28:02.132: INFO/dalvikvm(714):     at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
02-09 05:28:02.142: INFO/dalvikvm(714):     at dalvik.system.NativeStart.run(Native Method)


查了google是說cursor需要做close,小弟在程式中有三處去對db做query
其中一個地方是建立SimpleCursorAdapter然後給ListView去做呈現的,查了相關的資料寫說它會自己去控制cursor,因為若在這個地方把cursor做close的話,我的畫面上就沒有資料呈現出來了

本來這個錯誤訊息會出現2次,在剩下的2個地方小弟都把cursor做了close的動作,但還是會出現這樣子的錯誤訊息,我開了debug模式去看,這筆資料是在ListView上我點擊了其中一筆資料所產生出來的cursor的樣子,請教一下我是不是要在onListItemClick這個method中去close這個cursor呢??


vote up 0 vote down
reply to postreply to post
☆只要努力就有希望☆
作者 Re:cursor關閉時機 [Re:uxa]
borispong





發文: 18
積分: 0
於 2010-02-11 14:24 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
uxa wrote:
小弟在ListActivity中去query db,然後會把得到的資料傳給另一個Activity,在執行時都會發現

1
2
3
4
02-09 05:28:02.112: INFO/dalvikvm(714): Uncaught exception thrown by finalizer (will be discarded):
02-09 05:28:02.122: INFO/dalvikvm(714): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@435eea10 on rate that has not been deactivated or closed
02-09 05:28:02.132: INFO/dalvikvm(714):     at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)
02-09 05:28:02.142: INFO/dalvikvm(714):     at dalvik.system.NativeStart.run(Native Method)


查了google是說cursor需要做close,小弟在程式中有三處去對db做query
其中一個地方是建立SimpleCursorAdapter然後給ListView去做呈現的,查了相關的資料寫說它會自己去控制cursor,因為若在這個地方把cursor做close的話,我的畫面上就沒有資料呈現出來了

本來這個錯誤訊息會出現2次,在剩下的2個地方小弟都把cursor做了close的動作,但還是會出現這樣子的錯誤訊息,我開了debug模式去看,這筆資料是在ListView上我點擊了其中一筆資料所產生出來的cursor的樣子,請教一下我是不是要在onListItemClick這個method中去close這個cursor呢??


你好:
可以使用startManagingCursor()這個function來讓系統自己去管理cursor。


vote up 0 vote down
reply to postreply to post
作者 Re:cursor關閉時機 [Re:borispong]
uxa





發文: 441
積分: 6
於 2010-02-12 13:23 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
borispong wrote:
你好:
可以使用startManagingCursor()這個function來讓系統自己去管理cursor。


已經有使用這個方法了...但還是會看到系統跑出這樣的訊息Disapproved


vote up 0 vote down
reply to postreply to post
☆只要努力就有希望☆
作者 Re:cursor關閉時機 [Re:uxa]
koji

秒速5センチメートル

站長

發文: 7580
積分: 19
於 2010-02-15 01:21 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
你的東西跟這邊
http://developer.android.com/intl/zh-TW/resources/tutorials/notepad/notepad-ex1.html
差很多嗎?
跑他的東西會出現一樣錯誤嗎?

koji


vote up 0 vote down
reply to postreply to post
Facebook上的TWJUG社團,歡迎加入

» JavaWorld@TW »  Java ME、Google Android 平台與 JavaCard 討論區 » Android

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JavaWorld@TW


Powered by Powerful JuteForum® Version Jute 1.5.8
Copyright© 2002-2003 Rainman Zhu,Zua,Netboy,Scott. All Rights Reserved.