What Characters Allowed in File Names on Android

What characters allowed in file names on Android?


  1. On Android (at least by default) the file names encoded as UTF-8.

  2. Looks like reserved file name characters depend on filesystem mounted (http://en.wikipedia.org/wiki/Filename).

I considered as reserved:

private static final String ReservedChars = "|\\?*<\":>+[]/'";

Android: remove forbidden characters in filename

I guess this one will help you:

  • What characters allowed in file names on Android?

It reads that all UTF-8 are allowed (by default) but that there are some reserved characters.

With which do you have problems?

Allowed characters in filename

You should start with the Wikipedia Filename page. It has a decent-sized table (Comparison of filename limitations), listing the reserved characters for quite a lot of file systems.

It also has a plethora of other information about each file system, including reserved file names such as CON under MS-DOS. I mention that only because I was bitten by that once when I shortened an include file from const.h to con.h and spent half an hour figuring out why the compiler hung.

Turns out DOS ignored extensions for devices so that con.h was exactly the same as con, the input console (meaning, of course, the compiler was waiting for me to type in the header file before it would continue).

Restrictions on file names in internal storage?

It will generally follow unix style filesystem conventions. Most Android devices are now using ext4 format on flash media for internal storage. Originally yaffs2 was being used or even ubi/ubifs. But most OEMs have shifted to ext4.

max file name length in Android

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.

Naming rules for Android resources

The rules are the same as for Java identifiers since each resource must have a corresponding ID field generated in the R.java file.

Can the android application package name contain non-english characters?

No. Java package shall follow java package naming convention. See Android docs

What is acceptable file name in Android when storing to SD card

Some filesystems dont allow certain characters. You can check out which filesystem cant use which character here:
Link

In your case it is most likely FAT32, so:

Any byte except for values 0-31, 127 (DEL) and: " * / : < > ? \ | + , . ; = [] (lowcase a-z are stored as A-Z). With VFAT LFN any Unicode except NUL



Related Topics



Leave a reply



Submit