Persisting Images - Design Query

by Brian » Fri, 30 Apr 2010 15:57:55 GMT


Sponsored Links
 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

--



Other Threads

1. Screen protector WTA : galaxy tab

Numpang tanya lagi, screen protector yg clear dan tidak meninggalkan bekas jari 
buat gtab biasanya teman2 pakai apa ya? Tadi coba pakai bawaan capdase (sepaket 
sama case) cepat banget kotor. Terima kasih


Roy
@Globe Telecom BB

-----Original Message-----
From: "Roy" <mi...@roy.or.id>
Date: Mon, 28 Mar 2011 03:12:56 
To: <id-android@googlegroups.com>
Reply-To: mi...@roy.or.id
Subject: Re: WTA : galaxy tab

Thanks teman2 sepertinya saya jadi ambil, udah janjian sama yg punya besok, 
tinggal mastiin kondisi aja. 
Hmmm mungkin 3 jt bekas (nggak lengkap) harga yg wajar di philippine sini, coz 
harga baru di range 4.2jt-4.5jt (kalo dirupiahin). Terima kasih


Roy
@Globe Telecom BB

-----Original Message-----
From: Roy <mi...@roy.or.id>
Date: Mon, 28 Mar 2011 00:53:01 
To: <id-android@googlegroups.com>
Subject: WTA : galaxy tab

Mohon infonya rekan2 terutama yang memakai galaxy tab,
Saya berencana membeli galaxy tab kebetulan lihat di website lokal sini ada
yang jual bekasnya.
untuk kebutuhan saya terutama baca ebook format epub, apakah galaxy tab ini
mencukupi?
Program apa yang dipakai? apakah ada lag setiap kali membalik halaman buku?
Terus untuk harga, dengan kelengkapan minus box, ada case berbentuk buku.
Dengan harga 3 jt rupiah, apakah termasuk murah atau mahal.
Untuk {*filter*}tara itu aja dulu. Terima kasih

Roy


-- 
===============

2. lost the password of the keystore

I am doing an update on my application. I would like to sign it and
publish
However, when doing the process of jarsigner. It prompt me for the
passphrase, unluckily , I forgot the passphrase.
So, I would like to have some advice on it.

1) Is it possible to recovery/reset the passpharse of the keystore.
2) if passpharse recovery, reset is not possible. Am I needed to
delete the old publish and publish the apps with new package name and
new key signed? How can I notify the users installed the old apps to
download and install the new apps? Thanks a lot.

-- 

3. Difference between Phone and Tablet

4. how to install other language in android 锛焑x. nepalese .....

5. Silahkan dicoba m-taskkill

6. Preprocess AndroidManifest.xml ?

7. Under which category Motrola XOOM comes