Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Android
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Android
how to store the result of the request in table
Sarra Sakka
Ranch Hand
Posts: 283
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I created a method to store the result of the request SQLite in a table
public ArrayList <String> getProductName(double idcat) { ArrayList <String> tab = new ArrayList <String>(); try { Cursor c = null; c = database.rawQuery("SELECT " + COL_PRODUCT_NAME + " FROM " + TABLE_PRODUCT + " WHERE " + COL_CATEGORY + "= '" + idcat + "'", null); for(int i=0;i<c.getCount();i++) { tab.add(c.getString(c.getColumnIndex(COL_PRODUCT_NAME))); c.moveToNext(); } c.close(); } catch(Exception e) { e.printStackTrace(); } return tab; }
I want to get the number of elements in this table, so i put this :
ArrayList <String> tab = new ArrayList <String>(); TextView tv = new TextView(this); tab=db.getProductName(1); int n =tab.size(); tv.setText("n=" +n);
But when i compile my application, n get 0 !!!
Maneesh Godbole
Bartender
Posts: 11497
19
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Did you try setting a break point on line 10 of your getProductName method and see c.getCount() actually is?
[
How to ask questions
] [
Donate a pint, save a life!
] [
Onff-turn it on!
]
Sarra Sakka
Ranch Hand
Posts: 283
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I correct it by my self
It's lacks :
if(c.moveToFirst())
{ ...
}
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
put in LIST Sample Data to debug, also how view SQLITE DB Data from Eclipse IDE for debug purposes
telephonyManager.getCellLocation() gives null
Trying to collect wifi data like Metal Gear Solid Portable Ops
Android CustomListView getView() getting nullpointerexception
NullPointerException problem
More...