I have this SQLite containing a number of ‘Projects’. Each ‘Project’ with its attributes from the SQLite Database Table are displayed in an activity. What I wanna do is, when a button inside the activity is clicked, it updates the C_FAVORITE row of that ‘Project’.
How am I able to do so? Which arguments do I need to put inside the update method below?
public void makeFavorite() {
Database.Project.C_FAVORITE.update(.......);
}
this is how I display the attributes of the Project on the activity:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.project);
loader = new ImageLoader(this);
Intent intent = getIntent();
if (intent != null) {
Uri uri = intent.getData();
if (uri != null) {
final Cursor cursor = managedQuery(uri, new String[] {
BaseColumns._ID, Database.Project.C_PROJECTTITLE, Database.Project.C_ORGANIZATIONTITLE,
Database.Project.C_PROJECTDESCRIPTION,Database.Project.C_BIGIMAGE,Database.Project.C_DONATIONAMOUNT,Database.Project.C_ADDRESS,Database.Project.C_WEBSITE,Database.Project.C_SHORTCODE,Database.Project.C_KEYWORD,Database.Project.C_PRICE,Database.Project.C_CAMPAIGNID,Database.Project.C_PAYPALEMAIL,Database.Project.C_ELVAVAILABLE}, null, null, null);
if (cursor == null) {
finish();
} else {
if (cursor.moveToFirst()) {
ImageView img = (ImageView) findViewById(R.id.project_image);
TextView project_title = (TextView)findViewById(R.id.txt_project_title);
project_title.setText(cursor.getString(1));
……
You can try as follows:
If you have no where clause you can pass null there.