I am new at Android programming and trying to create an application which shows up pre-defined quotes, poems etc. I want to know what is the best way to store these strings in the application? SQLite Database, XML file, text file? Any suggestions for cloud storage and how to achieve that in an android app?
Thanks in advance!
It feels absolutely absurd to go for Sqlite, even if it's a thousand strings. Reading a plain text file one line at a time and storing the strings in a List or Array takes absolutely no time at all. Put a plain text file in /assets and load it like this:
public List<String> readLines(String filename) throws IOException {
List<String> lines = new ArrayList<String>();
AssetManager assets = context.getAssets();
BufferedReader reader = new BufferedReader(new InputStreamReader(assets.open(filename)));
while(true) {
String line = reader.readLine();
if(line == null) {
break;
}
lines.add(line);
}
return lines;
}
Alternatively go for JSON (or possibly XML), but plain text should be fine.