This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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.
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.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: How to retrieve image path from database and put into ImageSwitcher?