How to store image retrieved from url in a SQLite database?

protected Drawable Imagehandler(String url) {
        try {
            url=url.replaceAll(" ", "%20");
            InputStream is = (InputStream)this.fetch(url);
            Drawable d = Drawable.createFromStream(is, "src");
            return d;
        } catch (MalformedURLException e)
        {   
            System.out.println(url);
            System.out.println("error at URI"+e);
            return null;
        } 
        catch (IOException e) 
        {
            System.out.println("io exception: "+e);
            System.out.println("Image NOT FOUND");
            return null;
        } 
    }

    protected Object fetch(String address) throws MalformedURLException,IOException {
        URL url = new URL(address);
        Object content = url.getContent();
        return content;
    }   

this will convert your imageUrl to Drawble at runtime, then set the Drawble to Imageview of Gallery

Leave a Comment