1. Check out our companion app, Forums for Android! Download from Google Play

Remote drawables in Android 4.0.3

Discussion in 'Application Development' started by ro_eire, Sep 23, 2012.

  1. ro_eire

    ro_eire Member
    Thread Starter

    Oct 27, 2011
    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


  2. jonbonazza

    jonbonazza Well-Known Member

    Jul 13, 2010
    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.

Share This Page