1. Download our Official Android App: Forums for Android!

Apps Remote drawables in Android 4.0.3

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

  1. ro_eire

    ro_eire Lurker
    Thread Starter
    Rank:
    None
    Points:
    25
    Posts:
    5
    Joined:
    Oct 27, 2011

    Oct 27, 2011
    5
    0
    25
    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 Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    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

Loading...