What characters allowed in file names on Android?
On Android (at least by default) the file names encoded as UTF-8.
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
How to Add Apache Http API (Legacy) as Compile-Time Dependency to Build.Grade for Android M
Unable Instantiate Android.Gms.Maps.Mapfragment
Google Maps Android API V2 - Detect Touch on Map
Failed to Resolve: Com.Google.Firebase:Firebase-Core:9.0.0
Couldn't Load Memtrack Module Logcat Error
Android: Out of Memory Exception in Gallery
Google Maps Android API V2 Authorization Failure
Tabwidget Current Tab Bottom Line Color
An Established Connection Was Aborted by the Software in Your Host MAChine
How to Kill an Application with All Its Activities
Converting a Canvas into Bitmap Image in Android
Bad Class File Magic or Version
Passing Arraylist of Objects Between Activities
Autocompletetextview Backed by Cursorloader