1

I have an app I want to make for Android. I have decided to store the information I will display in a text file and parse it, rather than a database since the data is so simple.

The info is just two lines of text, a word and a short description of that word. I want the app to get each pair (word, description) from the text file and display it on a card in the app.

I stored the .txt file in Google Cloud Platform Storage and now I need help writing the code to access the file(s) and parse them to use in a Cards UI.

I can find no helpful examples of how to get this file then parse it in the app in a smooth way.

Patrick Costello
  • 3,616
  • 17
  • 22
Frank B.
  • 204
  • 5
  • 17

1 Answers1

0

You can use a client library to open the file and read it. For example, the Python client library is at https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/functions

and your code would look like this:

import cloudstorage

try:
  gcs_file = cloudstorage.open(filename, 'r', content_type='text/plain')
  # process as normal ...
except cloudstorage.NotFoundError:
  pass

Sample Java client code is at https://cloud.google.com/storage/docs/xml-api-java-samples

Lak
  • 3,876
  • 20
  • 34