I been working on creating a table in sqlite3 android. I would like to append some string to another string dependi开发者_开发问答ng upon the user input.. What i want is to make a SQL query in string format and then afterwards execute it!
Suppose,
String sql = String.format("create table if not exists %s (%s int primary key, %s INT, %s TEXT, %s TEXT)", className, C_ID, C_CREATED_AT, C_USER, C_TEXT);
Okay now I would like to add more columns, if user wants.. suppose user wants to have 5 columns how do I append 1 more column in the above string? And what if the user only wanted 1 column? I want to do it all dynamically depending upon user input!
I'm kind of familiar with append method but can't do it.. seems a bit difficult.. I would really appreciate if somebody could help,
Thanks Already (:
Use the StringBuilder class to concatenate strings. This is the preferred way to build strings.
Refer here: http://download.oracle.com/javase/tutorial/java/data/buffers.html
精彩评论