开发者

what kind of file should i use in android to reference information that i stored?

I have created an android app that calculates the numerical values of word, and gives you a list of other words with the same numerical value. The way I have been doing it, is storring the words and value in a .properties file. Ie. A line from a .proprties file called "myWords" will have something like: 61=you, then I just use a get() method to call it,

ie. String myString = ResourseBundle.get("myWords").get("61"); would return the string "you". Is there a better way to do this? My guess is that this is not the proper use of a .properties file, and I was wondering if there was another way to do this correctly. I want to include the file in assets folder of the app, and from my limited understanding of sqlite, you can create a file within android, but you can't just include a file in the assets folder, and then read it. So that said, is there some other type of file that I should use, or was I wrong about sqlite, or is the .properties file being used correctly开发者_Go百科?


SQLite is your best bet and is the best way to handle your data on an Android phone, that is why Google bundled it on Android in the first place, to avoid people the pain of dealing with files.

If you follow this Tutorial they will show you how to create your database in your computer and then load it up on your "assets" folder and access it from your Android application.

Hope that helps!


You can use a csv file, read it from the assets folder each time the app starts or only once after installation and then store the values in a database.

Take a look at my answer here on how to read the files included in your app (you would use a csv file instead of a libray, but it's still reading files): Hosting an executable within Android application

Edit: here's another example to read from the assets folder: Image uploaded from the android app space seems corrupted


You can try out database option. Here is an interesting tutorial on how to pre-populate a database and then ship it out in the APK.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜