How to avoid garbled code when reading and writing Chinese on Android
preface
The reason why Android reads the Chinese file is that the character format of the read file is inconsistent with that of the written file. Therefore, to avoid Chinese garbled code, write in a certain format when writing the file and read in a certain format when reading. In this way, there will be no garbled code. For other text reading, when you don't know what format, you can read the corresponding file information first and then transcode it accordingly.
The following is a class to avoid garbled code in Chinese reading and writing.
RWFile.java
Write a test demo project according to this class.
MainActivity.java
activy_ main.xml
Note: you need to add file read-write permission
summary
The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. If you have any questions, you can leave a message. Thank you for your support for programming tips.