Getting Value from Android SQLite and modify it using select query -


i'm trying old qty record , add new value, want know qty varchar in database , created method convert integer

this databasehelper methods

public void checkifexcist(context mctx, string recordname,         string valuecheck, string changedqty, string changedprice,         string changedpname) {      databasehelper mdbhelper = new databasehelper(mctx);     sqlitedatabase mdb = mdbhelper.getwritabledatabase();      cursor mcursor = mdb.rawquery("select * " + sqlite_table             + " " + recordname + " ='" + valuecheck + "'", null);      if (mcursor != null && mcursor.movetofirst()) {          toast.maketext(mctx, "available", 3000).show();         contentvalues values = new contentvalues();         values.put(qty, changedqty);         values.put(price, changedprice);         mdb.update(sqlite_table, values, product_name + "='" + changedpname                 + "'", null);      } else {         toast.maketext(mctx, "not available", 3000).show();         /* record not exist */     }  }  public int getquantity(int quantity, string pname, string tablename,         string myqty) {     string theqty = "nothing";     string selectquery = "select " + pname + "from " + tablename             + " " + myqty + "='" + quantity + "';";     cursor c = mdb.rawquery(selectquery, new string[] { "hello.txt" });     if (c.movetofirst()) {         theqty = c.getstring(c.getcolumnindex(pname));     }     c.close();      int convertedqty = integer.parseint(theqty);     return quantity + convertedqty; } 

and how use methods in class onclick method

                int myqty = integer.parseint(qty.gettext().tostring());             string mytitle= m.gettitle().tostring();             string mycategory = m.getcategory().tostring();             int mycategoryn = m.getordernum();             double myprice = m.getprice()*myqty;              int newmyqty = myadapterdb.getquantity(myqty, "productname", "country", "myqty");              myadapterdb.checkifexcist(activity, "productname", mytitle, newmyqty+"", myprice+"", mytitle); 


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -