'TextView and data structures with practically unlimited capacity?

I need a TextView-like widget that is able to show file contents of arbitrary size. Android default TextView can hold and display 2^31 characters, which is just 2GiB. Same with other data structures used for holding (linear) file contents such as ArrayList, ByteArray, CharSequence and similar with Int type length/size.

I'm looking for either third-party equivalents of the previously mentioned classes that I can use that can hold more data (preferably 2^63 or 2^64 bytes/characters), or an advice on what to do if there are no such third-party classes.


I thought about having an ArrayList of ArrayLists/ByteArrays/CharSequences/etc. but that would give me only 2^31^2=2^62 of characters/data, which is not ideal — but it is OK. And the equivalent of having an ArrayList of TextViews placed one after the other will not work as I need to allow user to interact with all data as in one widget. Updating the widget dynamically will not work either, as it still must hold N number of empty lines in order for the height of the widget to be proper, potentially crossing the limit of 2GiB.

I realize that all of these issues could be solved by overriding mentioned or more base/writing from scratch new classes — irrelevant in which way solved — but that would be cumbersome and error-prone process (especially for TextView) so I would like to avoid it.



Solution 1:[1]

I'm not aware that such widget exists. Here is my shot: It's not TextView capacity that could be a drawback. You can experiment with off-screen loading of the text. I suggest you consider the text source as input stream buffer that you can seek it as you scroll the TextView. Similarly to a paging results, but this time your source is a text file and the data is raw bytes.

Offscreen loading would be the buffer of text that is green and rendered text is in the red box. Entire source of text is the black box.

Now there is a problem when the textview is flinged, the offloading and onloading the buffer must be made really fast.

You'll probably need to use RandomAccessFile so you can read from your text source the off-screen buffer, from which you'll render the text in the TextView or multiple textviews (if you use paging).

Forcing the system to load 2^62 data is horrendous and slow.

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1