• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

How to retrieve image path from database and put into ImageSwitcher?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am developing an Android apps which include plenty of image for each attraction place. For example, when user clicks on UK, there should be specific for UK and when clicks on US, there are another images.

Currently I am using ImageSwitcher and hardcode to display the images

If I put the `R.drawable.UK_1,R.drawable.UK_2,R.drawable.UK_3` in the database, how can I put this image path in the final Integer[]? And all these codes are required to done in the AsyncTask since I need to retrieve the data from the database and display it while user clicks on certain attraction place.

Current Code:


Classes:

 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks to me like you are asking how to use the database (build table, insert your rows, query for output). If so, I would suggest you read this section of the Android API Guides: http://developer.android.com/guide/topics/data/data-storage.html. It has a section on SQLite which will have more detail than what we can describe here. Having some understanding of SQL will help as well.

But I am not sure your best option is to put the IDs in the database. The IDs are constant only in a version of your application. Every time you update your app you would need to re-create the data table. Also, do you plan on shipping all densities of all the location images to your users? That sounds like a lot of content to download.

What I would suggest is storing your images in the assets folder, using AssetManager to locate them, and using Bitmap methods to scale appropriately for the device. Then the database would hold the URI paths to the files, which would be constant between app updates (unless you change them) rather than IDs which might not be.
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic