Hi guys,
I'm new enough to Android development and am still getting to grips
with the framework. I'm building a simple application that will
display some products where each product will have a name, description
and an image.

I'm using SQLite to persist the product data and have found that
pretty straight forward so far. My question is around design and
finding the best practice to solve my problem.

My question is as follows...

Where should I store the images (.png files) that are shipped with the
application?

Given my basic knowledge I see a couple of options here
1. Store them in the res/drawable folder and access them as standard
resources e.g. R.drawable.image_name
2. Store them in the res/asset folder and access them using an
InputStream. This way I could store a URI in the database for each
image pointing to the file in the asset directory.

These approaches are fine if the data remains static, however we want
to add functionality where we will download new product data to the
device from the web.
When we download this data we can persist the name and description
part in the database (no problems here) but I'm not sure what to do
with the images. We cannot add these new images to the asset directory
with the existing images as the asset directory cannot be written to
at runtime. As far as I am concerned I have two options here

1. Use the MEDIA content provider to persist the image on the device
internal data store and store the image URI in the database to
identify the path to an image.
OR
2. Create a folder on the file system and write my new image files to
this folder. Then store the file path in the product database to
identify an image (Not 100%
sure this is possible, can someone please confirm)

The problem with both these approaches is that there is an
inconsistency between how my initial product images are stored and how
the downloaded image updates are stored. This seems like poor design,
to have your initial images in one place (res/asset) and your
downloaded image updates persisted using the MEDIA content provder.

I need advice on how best to approach this in terms of good clean
design and best practice. I dont need specific code examples as I can
figure out the implmentation myself once I've discovered what approach
to take.

Apologies for the long post but I've been looking at this for a few
days now and have been doing quite a bit of head scratching. I'd like
to start my Andorid development off using best practices so I was
hoping some of the more experienced guys could assist.

Thanks
Brian

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to