Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Android sqlite : set a specific value on autocomplete,incrementation and more  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.I have an app that does the following : it has 3 columns(product name,quantity and price) of autocomplete/edittexts that are created dynamically.The one with the the product name and the price are the autocomplete ones.That autocomplete is connected to a sqlite database with product names and prices.
What i want to do is get the prices in the database as well,that's easy,i think i've done it right,didn't check but should be fine.
Now,what i want to do with that price is this : Lets say the user enters "Ch" ,in the product name autocomplet i get as autocomplete options Cheese and Chicken.After the user selects one option and it gets entered inside the autocomplete,i want the price autocomplete to get the price from the database and show it as an option in the autocomplete( i know it's going to be the only option but it doesn't matter.I don't want it to setText,just be an option for autocomplete).

Also,if the user enters Cheese with the price 2.5 it gets inserted in the DB.After that if the user enters Cheese with 3,i want it to get updated,to always have in the database the last price entered for that product.

How can i achieve this ? I have no clue..

Also,another issue : how can i count how many times a name is entered in the database ? My names are unique,no duplicates but i want it to count for example if a user enters Cheese for the first time,it gets inserted in the database.After that if app tries to insert Cheese again,the counter will get incremented.

If you could please show me how to adapt those things to my code,i'd appreciate it a lot,i've been struggling with this for a couple of days now...i'm an absolute beginner with sqlite.

And this is how i read from the database :

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!