I have my Android application which needs to send data to server after certain limit of memory is reached. I am checking internal memory left using -
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
long bytesAvailable = (long)stat.getBlockSize() * (long)stat.getAvailableBlocks();
long megAvailable = bytesAvailable / (1024 * 1024);
Log.e("","Available MB : "+ megAvailable);
Suppose Available MB initially is 800MB. I have an ArrayList of objects that keeps on adding elements every 10 seconds. Once my Available MB becomes 700MB, I want my data in ArrayList to be sent to server.
I wanted to know that when Available MB becomes 700MB-
a) how to retrieve data from ArrayList from 0th position until the current position(the position at which Available MB becomes 700MB) and send all at once.
b) After sending clear the arraylist and start storing new data until Available MB becomes 600MB