java - Updating a SQLite entry row -


I'm looking to update a line in the SQLite data base. What am I thinking, can I update a line without entering the user in the line? At the moment, my code requires that line IBA be passed in DBAdapter, but I would like to finish it and just want to update the row using two other variables (items and liters). Is this also possible?

This is my update function in my DBEdapter category

  // --- A record - Public Boolean update record (long line ID, string item, string liter) { ContentValues ​​args = new content value (); Args.put (KEY_ITEM, item); Args.put (KEY_LITRES, liters); Return db.update (DATABASE_TABLE, Args, KEY_ROWID + "=" + rowId, null)> 0; }  

This is my updated class,

  package com.example.rory.dbtest; Import android App Import android.content.Intent; Importroid.os.Bundle; Import android.view.Menu; Import android.view.MenuItem; Import android.view.View; Import android.widget.Button; Import android.widget.EditText; Import com.pinchtapzoom.R; Extends public category update activity {public editing text update item; Public Editing Text Update Litter; Button update BTN; DBAdapter db = new DBAdapter (this); @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); SetContentView (R.layout.activity_update); UpdateBtn = (button) findViewById (R.id.updateBtn); UpdateItem = (edit text) findViewById (R.id.updateItem); UpdateLitres = (EditText) findViewById (R.id.updateLitres); } Public Zero onClick (see V) {string item = updateItem.getText (). ToString (); String liter = update lighttrack.gettext (). ToString (); Db.updateRecord (line ID, string item, string liter); } @ Override Public Boolean On Crate Option Menu (Menu Menu) {// Expand Menu; It adds the item to the Action Bar if it exists GetMenuInflater (). Flood (R.menu.update, menu); Back true; } @ Override Public Boolean On Option Itam Select (Menu Item) {// Handle Action Bar Item Click here Action Bar will automatically click on the Home / Up button, so long as you // in AndroidManifest.xml Specify basic activity. Int id = item.getItemId (); If (id == R.id.action_settings) {return true; } Return Super.Options item selected (item); } // When returning to the first activity, when these works are called here, print records public zero visual assessments (see V) {intent i = new intent (this, MyActivity.class); StartActivity (i); }}  

I am using this section of code in my project. @ Override Public Int Update (Uri Yuri, Content Value Value, String Selection, String [] Selection ARGS) {String SQL = "Update Table_name SET Product_quote =" "+ value.getAsString ( "Product_qty") + "\ 'where line_ID = \'" + Selection Segment [0] + "\ '" + "; "; Logs. E (" sql ", sql); .db_cc.getWritableDatabase () execSQL (SQL); return 0;}

Where I select [0] of the selection array in my row_id I am passing in the post, and in my case I want to update product_qty so I passed that value using the content value.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -