0

I have a listview with a textview in each row. I am using a custom adapter to populate the each textview for different listview items from database, which also has a holder.textview.onclicklistener on the textview.

Problem is that I want to update database on click of textview for different list items, but getContentResolver() method, used to update the database does not work in holder.textview.onclicklistener.

Any ideas on how to update the database on click of textview present in listview items?

2 Answers 2

1

You just need a Context instance to call getContentResolver(). You can get one from the View that is passed to the onClick() method, i.e.

    @Override
    public void onClick(View v)
    {
        ContentResolver cr = v.getContext().getContentResolver();
        ...
    }
Sign up to request clarification or add additional context in comments.

Comments

0

Hence you show nothing in your code, this might be a great help of updating your database items;

http://www.vogella.com/tutorials/AndroidSQLite/article.html

and for updating the listview this will be great thread;

refresh ListView after delete from database

Hope it helps u. Cheers!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.