I am developing an android application and i need to read words from a file to create a Trie. Is there a way i can write the file to internal storage on install so that only my application can access it, or should i hard code the words. Any suggestions are appreciated
Asked
Active
Viewed 82 times
1 Answers
2
If the file isn't going to change, you should put it in your assets directory. If it is going to change, you can copy it from your assets to internal storage and it'll be private. External storage (often an SD card) is word-readable.
http://developer.android.com/guide/topics/data/data-storage.html
http://developer.android.com/reference/android/content/res/AssetManager.html

Darshan Rivka Whittle
- 32,989
- 7
- 91
- 109
-
Thank you exactly what i was looking for. To go along with the question is there a way i can run a method to populate data from this file on app start? – Darussian Jun 14 '12 at 00:46
-
@Darussian I'm not sure what you mean -- you can do whatever you want when you app starts, including reading from a file in your assets or internal storage... – Darshan Rivka Whittle Jun 14 '12 at 00:55
-
You can do pretty much any normal unix-style file operation on a file in your internal storage. Be aware though that these files are not private from the superuser - ie, on a rooted device they can be read/changed. For packaged assets, although there is no formal api for doing so, the contents of your entire apk including assets folder can be read by other applictions or by the user of a non-rooted device. – Chris Stratton Jun 14 '12 at 01:05