1. 2015 is going to be a great year for Android! Why wait??
    Samsung Galaxy Note 5 | Samsung Galaxy S6 | HTC One M9
  2. New Forum Created: Samsung Gear VR!

Remote drawables in Android 4.0.3


  1. ro_eire

    ro_eire Member

    hi, Im developing an app which is a product catalogue. Users can search for and view products (books). It's all read only and just so allow user's to view products. When the user clicks on a product, the next screen displays
    - book title
    - book author
    - picture of front cover.

    It's the picture part that I've a question about. I know one way to present drawables is to have them in the "drawable" direction in my android project and access them (in my xml file) as android:src="@drawable/name".

    Only problem is that new products will be added so I can't store drawables in the APK file when I release it. I'll need to read them at runtime. I'm wondering what the best way to approach this is.

    I'm thinking of upon app launch executing an AsyncTask which would call
    openConnection of HttpURLConnection and would grab down all drawable (from a particular remote directory on a website) and would then store them in the sqllite db (as a blob). Each product in the db could easily be associated with it's specific drawable.

    Not sure if there's a better approach to this ? or should I save them to the internal storage of the device (I know the size is an issue with this option). Or I could, when I show the product, call the Async task to present the image - i.e.get the image when the user requests it. This sounds good (in a lazy loading kinda way)..

    any help would be great. I'm developing on Android 4.0.3.

    Thanks - Ro

    Advertisement
    :
  2. jonbonazza

    jonbonazza Well-Known Member

    You are on the right track, however it's not a good practice on Android to store BLOBs. Instead, we tend to store them on the sdcard and then store the URI for the file as a VARCHAR in the db.
Loading...

Share This Page