Is there a way to retrieve the file path of an Android CacheResponse
? Sure, one can get an InputStream
, but in cases where some API (e.g. NDK code) expects a file path that does not help. Sure one can use this stream to produce another file, but that's more time and space.
Asked
Active
Viewed 73 times
1

DMH
- 3,875
- 2
- 26
- 25

user6519354
- 169
- 1
- 7
2 Answers
1
I've run into this myself.
On Android (tested on Jellybean), the cache file path is the lowercase MD5-sum of the URI followed by
.1
So for the URL Android CacheResponse: get file path? the following files exists in the cache-directory.
- bf9b8f9a33062f084a70cba99dc79afe.0 - contains the headers of the HTTP response
- bf9b8f9a33062f084a70cba99dc79afe.1 - contains the body of the HTTP response

Community
- 1
- 1

Erik Gustavsson
- 11
- 2
0
Ok, so pondering this a bit further (and poking at the code), I have to assume that response headers, etc, are in the same file -- not just the response body. If so, then there would clearly be no file path one could provide that was simply the response body. Confirmation would be helpful -- as would pointers to alternative HTTP caching libraries that would help here.

Jess Holle
- 633
- 5
- 15
-
Actually it appears the underlying implementation retains separate metadata and body files -- great! But I don't see a good way to actually get the body file path. – Jess Holle Jun 28 '16 at 12:59
-
Is there still no way to get the local file path? – IgorGanapolsky Feb 16 '18 at 13:53