0

Are there any other methods to adding static data to a textview?

Example: I currently have an activity friendship.xml and there would be a textview box, the content/text of this is currently defined as @string/friendship.

This is configured under the strings.xml as :

"<string name="friendship">someday long long time ago.\n
there was a man who\n
was was going to\n
his bla bla bla\n </string>

So although I'm getting the "content" into the textview, I'm wondering if it's not the wrong way of doing it, considering my strings.xml file would probably end up being 80MB of the application itself, and what other methods would be available, keeping in to consideration formatting etc.

Mateusz
  • 3,038
  • 4
  • 27
  • 41

2 Answers2

0

80Mb? Are you writing a novel?

If you reuse certain lines multiple times then that is really the way to go. If not, break the sections down so you can reuse certain segments instead of having a bunch of repeats in your .xml file.

You could have a class or enum that is used to hold all the string literals so you can enter the text via code, but that would still take up the same amount of space. Probably even more.

eddiecubed
  • 174
  • 1
  • 2
  • 12
  • hehe, not exactly, but the app will have a lot of content in it, on various topics. Maybe the 80mb is exaggerating a bit, worst case scenario I guess (:-p) – Frikkie Jul 11 '13 at 16:12
  • why not break it into chapters or sections and make them retrievable from a url or something. Some way to have the app retrieve a text file from some url and have it in a sqlite database. I don't know much about the file retrieval but, it seems doable. The sqlite database is only scary if the user clears database from settings, which would make your app useless then. – eddiecubed Jul 11 '13 at 16:47
0

Maybe you can use a file with all the string content. see http://developer.android.com/guide/topics/data/data-storage.html#filesInternal

user1566464
  • 103
  • 1
  • 14