Store static data in Android - custom resource?

前端 未结 4 559
旧时难觅i
旧时难觅i 2020-12-08 01:28

I\'m new to Android development, and I\'ve been playing around with it a bit. I was trying to create a program that has a small database-like collection of never-changing d

4条回答
  •  轮回少年
    2020-12-08 01:48

    The best way is to use the Android Resource Heirarchy.

    In the res/values/ directory, you can store any number of key-value pairs for several basic data types. In your app, you would refer to them using an autogenerated resource id (name based on your resource's key). See the link above for more documentation and details.

    Android also supports raw datafiles. You could store your data in the file directory under res/raw/yourfile.dat

    You you create your data in whatever text based format you want and then read it on activity startup using the resource access apis.

提交回复
热议问题