java - Size of file using Android Internal Storage -
i'm using:
fileoutputstream fos = getcontext().openfileoutput(filename, context.mode_append); to store strings of data file filename. want ensure stop appending more strings when string within filename has reached 120kb. how query total space taken?
i've tried:
file file = new file(getcontext().getfilesdir() + "/" + filename); log.i(tag, "storage used (bytes): " + long.tostring(file.gettotalspace())); but returns me huge number. because way i'm referencing directory wrong?
use method length() instead. documentation
returns size of partition named abstract pathname.
returns length of file denoted abstract pathname. return value unspecified if pathname denotes directory.
so gettotalspace checking information folders or drives.
Comments
Post a Comment