0

I have been looking for a while but haven't been able to find an answer. I have a text view in my APK that needs to potentially handle large amounts of text being appended to it a little at a time. So it could grow over time as stuff streams to it. So far I haven't seen any issues and I have let the underlying Android implementation take care of the data. Does anyone know if Android caches these all in memory or that if it passes a watermark level it could then write to file for the TextView? What if it gets too huge, would the APK run out of memory and get killed by Dalvik? If that is the case I am open for any suggestion as how to mitigate this possiblity. One solution in my mind is that have a custom textview that does exactly what I explained and caches data to file if it passes a water mark. However, I am not sure how tricky it would get to detect where the user is navigating within the TextView to pull the data back and forth from the underlying data file and populate the actual TextView object.

Thanks

  • What about if you have a ListView with several TextView. Each TextView will have a limit, let's say 1000 chars. – Axxiss Jul 23 '13 at 15:20
  • I haven't seen any such limits I am more concerned about the underlying implementation as I think it will eventually hit a memory limit if not cached to flash. – user2608129 Jul 23 '13 at 18:06

1 Answers1

0

While I was unable to find the actual threshold, it has been discussed and suggested that extremely long text be displayed in smaller chunks. You can also write to a file which you can then read back in as necessary for your project.

Edit: regarding the TextView bookmark (for lack of a better term), you could always programmatically check to see where the user is in the TextView (checking for a certain character or string at the end of the TextView) and reading the next few lines of text into the TextView. You would have to match the getText().toString() value of the TextView against the readable text in your file.

I'm wondering now too if you would be able to do that in either direction. To save space, you could write your text to file as the user needs it, and update the TextView to only display 5 or 6 lines (arbitrary number). You could trim the TextView in either direction to save memory. You could ellipsize both sides of your text, scroll enable it, and trim/read those points as necessary.

Community
  • 1
  • 1
Phoenix
  • 1,881
  • 5
  • 20
  • 28
  • Thanks for the suggestions. Comparing the textview content and the file content wouldn't be an option as my data could be very repetitive and there will be many possible matches that could indicate incorrect current location within the file. There needs to be another way to sync the file to the textview. – user2608129 Jul 24 '13 at 15:41