I started Android Programming few days ago and make a simple application using JSON request. I have some problems to print to the output console the content of a string. Indeed, the JSON response is quite big (.length() return 93k ) and when I print it with System.out.println, there is only 4013 printed char. How can I retrieve the whole string ? (Or write it to a log file) ?
You can use recursion, for example
private void longMsg(String msg) {
if (msg.length() > 4000) {
System.out.println(msg); // or whatever you want
longMsg(msg.substring(4000));
} else {
System.out.println(msg); // or whatever you want
}
}
May be it will be better for you to output it on device screen? As TextView element.
Or write it in file, using solution like this.
Do not forget to add permission for that in AndroidManifest.xml
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
/>
For future, to parse JSON use classes from org.json package, they are very easy and helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With