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

gettotalspace:

returns size of partition named abstract pathname.

length:

returns length of file denoted abstract pathname. return value unspecified if pathname denotes directory.

so gettotalspace checking information folders or drives.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -