0

I have Nexus 4 and it's giving me no problems. But when I tried my code on micromax canvas it threw an IOException "invalid arguments" while trying to save a file with an encoded filename.

I am using this line to convert the file name.

Base64.encodeToString(name.getBytes(),Base64.DEFAULT))

where name is the filename (example:hello.jpg).

Basically I want to convert the filename so that no one can even search it in sd card.

I think the problem is that the FAT file system supports filename length up to 42 characters but it is producing longer file names. I have also tried URL safe and no padding instead of default in Base64.

I need to know some alternative solution.

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
IDS
  • 35
  • 1
  • 7

3 Answers3

0

For work-around purpose, try to use a custom class for encoding and decoding

More info: "IllegalArgumentException: bad base-64" while trying to use Base64 on Android 1.5

Community
  • 1
  • 1
Vinay Pareek
  • 111
  • 1
  • 7
  • my app is for only android 3.2+. The problem I think is the long filename produced by Base64 https://play.google.com/store/apps/details?id=com.ids.smartcalculator – IDS Dec 08 '13 at 15:20
0

I have fixed this issue in app but used a different method instead of base64

laalto
  • 150,114
  • 66
  • 286
  • 303
IDS
  • 35
  • 1
  • 7
  • Hi, I removed the link to your app as it is not relevant to the question/answer at hand and to avoid being flagged as spam. However, to make this answer actually an answer, please describe your workaround here. – laalto Dec 09 '13 at 11:15
  • my workaround was to ignore encoding on the devices in which it will show error by catch(exception) :D – IDS Dec 09 '13 at 15:20
0

i guess this should work

String filename = Base64.encodeToString(url.getBytes(), Base64.URL_SAFE|Base64.NO_WRAP);