final Context contextfill = context;
new Thread() {
@Override
public void run() {
try {
// Fill up all the memory
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
int totalBlocks = stat.getBlockCount();
int noOfBlockToFill = stat.getAvailableBlocks();
FileOutputStream fs =
contextfill.openFileOutput("testdata", Context.MODE_APPEND);
for (int i = 0; i < (noOfBlockToFill / NO_OF_BLOCKS_TO_FILL); i++) {
byte buf[] = new byte[mBlockSize * NO_OF_BLOCKS_TO_FILL];
fs.write(buf);
fs.flush();
}
// Fill up the last few block
byte buf[] = new byte[(noOfBlockToFill % NO_OF_BLOCKS_TO_FILL) * mBlockSize];
fs.write(buf);
fs.flush();
fs.close();
// Finished, update the info
synchronized (fillUpDone) {
fillUpDone.notify();
}
} catch (Exception e) {
Log.v(TAG, e.toString());
}
}
}.start();