简体   繁体   中英

Java/Android - Most efficient way to store many variables

I'm creating an app and I need to store hundreds of strings that can be called or used in if/else functions. I was thinking about using SQLite to try and hold a load of them but I'm not very experience with it and I'm not too sure how I can manually store strings in it. Is there a simpler way to store many different strings besides using a large array or a database?

You need to ask yourself how you're going to use these strings. Will you load them all once into memory when the app starts up or will you constantly be pulling bits and pieces throughout the application's life-cycle? If your answer is the latter than a viable option in Android would be to use SharedPreferences which uses a key/value pair format to store data on the device. If your answer is the former then a database (SQLite) would probably be better.

See Google's documentation for more information on SharedPreferences.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM