John Smith
John Smith

Reputation: 2738

max file name length in Android

I am trying give a name for a file that I am creating. I just want to know that what is the max file name length in Android ?

Is there a specification for a file name? Can I use characters like - or > ?

Upvotes: 32

Views: 32451

Answers (5)

XXX
XXX

Reputation: 9072

max file size in Android is

255

Upvotes: -2

earl baversjo
earl baversjo

Reputation: 11

I have found that '-' (period) is a standard in naming as a rule. Frequently you will see special characters to create readability, such as the '.' Yet, the period is a constant for separating the filename from the filetype nomenclature regardless of the OS. This rule goes back to the earliest days of computing. The thing that younger users do not realize is how rigid the rules were in those early years. Modern protocol, on the other hand makes more use of assumptions to shorten code so it takes less space. Just as your smartphone is smaller than an old IBM360, so too is modern instruction set.

Upvotes: 1

enreas
enreas

Reputation: 11262

In the specific case of resource names, like images, I've found that the max length is 100 characters, extension included. I've checked this in Android Studio 1.2 beta. I'm sure there must be something about this in the Android documentation.

Upvotes: 1

Mel
Mel

Reputation: 281

It is apparently unsafe to use labels over 127 bytes on Android. AFAIK, the 255 limit is a goal, but is a WIP. I trashed my Galaxy Tab 10.1's sdcard file system last week when music sync software generated some filenames of around 160 characters. Limiting the filenames to 127 solved the issue. Be safe, unless you are sure of your particular release... stick to a limit of 127.

Upvotes: 28

Jong
Jong

Reputation: 9115

About the characters: Reading here, looks like - is not a reserved character, so it may be used. > however, is reserved therefore may not be used.

About the maximum length: Since I couldn't find anything specific to Android, and since java does not restrict the length of a file name it works with (As you can see here), I'd say the maximum length is like the most widely used limit, which is 255 bytes.

Upvotes: 15

Related Questions