开发者

How do I append an other string in string.format() method dynamically!

开发者 https://www.devze.com 2023-03-04 00:48 出处:网络
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

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

0

精彩评论

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