I have code to upload pictures to the server and it works okay. However, when there is no internet, i would like the picture to be saved temporarily in the Imageview then uploaded automatically when internet becomes available (Pretty like what i see in Whatsapp). How is this implemented in Android?
Asked
Active
Viewed 111 times
0
-
Where is the picture? Where does it come from? Please start at the beginning. Put all in your post. – blackapps Oct 29 '19 at 10:34
-
the picture is from the phone's gallery to be loaded first to the imageview in an activity then uploaded to a remote webserver – user3267567 Oct 29 '19 at 14:42
-
If it comes from the gallery then why would you save them again? Just remember the path will do. – blackapps Oct 29 '19 at 15:56
1 Answers
1
You can do that by the following way
- Store your all
image
in a directory. You can usecontext.getFilesDir()
(internal files directory of projects). - Add a BroadcastReceiver to listen to Internet Connection.
- when internet is available, get the file list from files directory and upload each file and delete it after upload completed. [to get file list do like
context.getFilesDir().listFiles()
]

Jakir Hossain
- 3,830
- 1
- 15
- 29