I'm creating this app for Android and I need the app runs on offline environment. At some point the user will be online and sync his data with the server to download changes and it should still using the app after that when he will be offline. On situation is this: the user log in and the app check with Internet that the account really exists, if the account exist it will download user data like information and profile picture. The communication between the app and the server is created with Retrofit, so the server returns a JSON like this:
{
"data":{
"username": "John Doe",
"avatar": {
"original" : "http://url/to/picture.jpg",
"p35x35" : "http://url/to/picture.jpg" }
}
}
and I convert that JSON to Object and store it on a database. (Please don't worry if you see any mistake on the JSON, I wrote it myself). The situation is with the pictures, they come as Internet URL but I need to store it local, I can't save URL links on the database. I don't know which is the best way I should do that. I've consider many ways but I don't like them, I don't know if they're fine and I'm not sure which is the best way for this:
1 - Using Picasso for cache handling, I don't like this option because cache can be deleted and I believe Picasso is more oriented to online apps that maybe are offline sometimes but most of time are online.
2 - Download every picture to a local folder, rename it with his SHA1 or MD5 and set that name to the database as the "original" and "p35x35" fields.
3 - Store the pictures locally with the same path as they're on Internet, ex- "storage/emulated/.application/.images/url/to/picture.jpg"