Android does not allow native apps like Phonegap-based apps to write binary files. A common application is converting Base64 Strings to Images. So, how do you go about this problem?
Android does not allow native apps like Phonegap-based apps to write binary files. A
Share
The solution; This plugin that converts a Base64 PNG String and generates an image to the sdCard. Let’s go!
1. The Base64 Decoder
Get this blazing fast Base64 encode/decoder class called MiGBase64. Download it from SourceForge. Create a folder called ‘util’ within your project’s src/ folder. Place the downloaded class there.
2. The java
Create a folder called ‘org/apache/cordova’ within your project’s src/ folder.
Create in it a Java file called “Base64ToPNG.java” with the following source code.
3. The Javascript
Write this JavaScript as Base64ToPNG.js to your project’s www folder. DONT forget to include a reference to it in your html files.
4. The plugins.xml file
Add the following to res/xml/plugins.xml file
5. Finally, HTML examples and the parameters
Parameters
overwrite: If the file already exists, replace it. By default false.
I hope this answers some bothering questions. Happy coding!