0

I am working with gif images at the moment and have followed the answer from the question here

From this I have the following line of code:

    GifWebView view = new GifWebView(this, "http://cdn.lifebuzz.com/images/17487/lifebuzz-35df9a5ee351ae72711e5a293658e319-limit_2000.gif");

Now, I want to download this image, save it locally in the "drawable" folder or "assets" folder and then access it from there.

I have tried downloading the image into the "drawable" folder and trying :

    GifWebView view = new GifWebView(this, "@drawable/myimg.gif");

I have also tried this:

    int imageResource = R.drawable.myimg;

    Drawable image = getResources().getDrawable(imageResource);

    String imageUri = "drawable://" + R.drawable.myimg;

    GifWebView view = new GifWebView(this, imageUri);

Still no luck.

I've tried accessing it from the assets folder but this seemed even more complicated.

I just would like to save it locally and access it locally, I don't really care where it is stored.

Thanks for any help.

EDIT

public GifWebView(Context context, String path) {

    super(context);        
    loadUrl(path);
}
Community
  • 1
  • 1
Greg Peckory
  • 7,700
  • 21
  • 67
  • 114
  • "save it locally in the "drawable" folder or "assets" folder and then access it from there" no no no, its basically not possible, save it in app's local data path – pskink Jun 24 '15 at 12:03
  • do I have to access URL then? – Greg Peckory Jun 24 '15 at 12:04
  • Where is this local data path, and how would I access it? Thanks for the answer btw – Greg Peckory Jun 24 '15 at 12:05
  • see android.os.Environment – pskink Jun 24 '15 at 12:07
  • Why can I not use drawable or assets? I basically want to avoid using internet connection. That is all. – Greg Peckory Jun 24 '15 at 12:08
  • you can use assets of course but it is read-only beast, you can read from them but cannot insert anything at the runtime – pskink Jun 24 '15 at 12:09
  • Yes, I only need to access the image to view on screen. How would I use this file path in the above context? – Greg Peckory Jun 24 '15 at 12:12
  • so if you have an image place it in some drawable folder, but im confused what do you mean by remote url like cdn.lifebuzz.com/images/17487/lifebuzz-35df9a5ee351ae72711e5a293658e319-limit_2000.gif and that you dont want to use internet? – pskink Jun 24 '15 at 12:14
  • aha i see now: what are params of GifWebView? does it only accept some url? – pskink Jun 24 '15 at 12:16
  • I have added the constructor for GifWebView in question – Greg Peckory Jun 24 '15 at 12:21
  • try it with file:/// then – pskink Jun 24 '15 at 12:22
  • also you could try scheme described for AssetFileDescriptor#openAssetFileDescriptor, see http://developer.android.com/reference/android/content/ContentResolver.html#openAssetFileDescriptor(android.net.Uri, java.lang.String) i mean SCHEME_ANDROID_RESOURCE one of android.resource://package_name/type/name or android.resource://package_name/id_number – pskink Jun 24 '15 at 12:26
  • What exactly would be in the path name beginning with `file:///`, I have tried many ways using Assets folder and none worked. Found about 3 or 4 different potential answers on StackOverflow – Greg Peckory Jun 24 '15 at 12:27
  • first try one of android.resource://package_name/.. from my last comment, if it doesn't work i am afraid you have to copy your asset to some physical file and use file:///full_file_path – pskink Jun 24 '15 at 12:29
  • save it in cache and load from this path, but first you need a class to download the gif image from url – Santiago Jun 24 '15 at 13:15
  • @pskink It worked - `file:///android_assets/myimg.gif`. Thanks a mill! – Greg Peckory Jun 24 '15 at 15:34
  • thanks for what? you discovered this: file:///android_assets, not me... :) – pskink Jun 24 '15 at 15:56

0 Answers0