i want to write this line in an sqlight db b:
CREATE TABLE "android_metadata" ("locale" TEXT DEFAULT 'en_US')
therefore in my java file who generate this data base i am doing :
stat.executeUpdate("create table "+"android_metadata"+"("+"locale"+ " TEXT DEAFULT"+");");
PreparedStatement prep1 = conn.prepareStatement(
"insert into "+"android_metadata"+" values (开发者_如何学JAVA?);");
prep1.setString(1, "en_US") ;
but the output is not similer how do i make the sqlight locale be "locale" with "" in the declaration and the field locale would be just TEXT
as similer to this blog start : http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
thanX
To escape the double quotes use a backslash:
stat.executeUpdate("create table \"android_metadata\" (\"locale\" TEXT DEFAULT 'en_US');");
Also I think you don't need double quotes round android_metadata
as it is not an SQL keyword.
You need to escape the quote symbol (and fix a typo - DEAFULT)
stat.executeUpdate("create table \"android_metadata\" (\"locale\" TEXT DEFAULT 'en-US');");
The java String equivalents are:
// CREATE TABLE "android_metadata" ("locale" TEXT DEFAULT 'en_US')
final static private String create = "CREATE TABLE \"android_metadata\" (\"locale\" TEXT DEFAULT 'en_US')";
// INSERT INTO "android_metadata" VALUES ('en_US')
final static private String insert = "INSERT INTO \"android_metadata\" VALUES ('en_US')";
EDIT upgraded the code according to duffymos comment :)
精彩评论