Game Development Reference
In-Depth Information
the text file is encoded as UTF-8. The rest is just catching and handling various exceptions.
Figure 4-10 shows the output of this little activity.
Figure 4-10. The text output of AssetsTest
You should take away the following from this section:
InputStream in Java is a mess! Usually, we'd
do that with something like Apache IOUtils. We'll leave that for you as an
exercise to perform on your own.
ï?®
Loading a text file from an
ï?®
We can only read assets, not write them.
loadTextFile() method to load binary data
instead. We would just need to return the byte array instead of the string.
ï?®
We could easily modify the
Accessing the External Storage
While assets are superb for shipping all our images and sounds with our application, there are
times when we need to be able to persist some information and reload it later on. A common
example would be high scores.
Android offers many different ways of doing this, such as using local shared preferences of
an application, using a small SQLite database, and so on. All of these options have one thing
 
Search WWH ::




Custom Search