다음을 통해 공유


Formatter.FormatFileSize(Context, Int64) Method

Definition

Formats a content size to be in the form of bytes, kilobytes, megabytes, etc.

[Android.Runtime.Register("formatFileSize", "(Landroid/content/Context;J)Ljava/lang/String;", "")]
public static string? FormatFileSize (Android.Content.Context? context, long sizeBytes);
[<Android.Runtime.Register("formatFileSize", "(Landroid/content/Context;J)Ljava/lang/String;", "")>]
static member FormatFileSize : Android.Content.Context * int64 -> string

Parameters

context
Context

Context to use to load the localized units

sizeBytes
Int64

size value to be formatted, in bytes

Returns

formatted string with the number

Attributes

Remarks

Formats a content size to be in the form of bytes, kilobytes, megabytes, etc.

As of O, the prefixes are used in their standard meanings in the SI system, so kB = 1000 bytes, MB = 1,000,000 bytes, etc.

<p class="note">In android.os.Build.VERSION_CODES#N and earlier, powers of 1024 are used instead, with KB = 1024 bytes, MB = 1,048,576 bytes, etc.</p>

If the context has a right-to-left locale, the returned string is wrapped in bidi formatting characters to make sure it's displayed correctly if inserted inside a right-to-left string. (This is useful in cases where the unit strings, like "MB", are left-to-right, but the locale is right-to-left.)

Java documentation for android.text.format.Formatter.formatFileSize(android.content.Context, long).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to