Click here to Skip to main content
15,844,903 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi is there any tutorials on android sqlite counter, when item is clicked once, the count in database will have increment by one.
Krunal Rohit 2-Nov-15 4:24am    
Don't repost the question. Yesterday I've commented on your question that you have to fire the update statement whenever your item is clicked.

Benji Heng 2-Nov-15 4:29am    
I understand I have to have the update statement but how do I do it? I even made edits to the codes, please do take a look

That is a combination of two objects.

1. SQLiteOpenHelper
2. OnClickListener

These would (collectively) work to accomplish the task. The helper would allow you to work around with SQLite databases, like accessing or updating the values and the click listener would allow your application to handle the taps by user.

Start by this tutorial, Using SQLite Database with Android[^], then the listener[^] can be added to the items in your list to trigger the helper to update the values.
Share this answer
Why do you need a button click? SQLite, like most databases, provides for an automatic incremented field: see[^].
Share this answer
Benji Heng 2-Nov-15 4:34am    
The issue is, I already have a id that is INTEGER PRIMARY KEY autoincrement
Richard MacCutchan 2-Nov-15 4:56am    
Then please edit your question and explain exactly what you are trying to achieve.
Benji Heng 2-Nov-15 10:04am    
I have the questions here please take a look
Richard MacCutchan 2-Nov-15 10:30am    
I don't see any update to your question.
Benji Heng 2-Nov-15 11:21am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900