我在Android工作室遇到了烦人的问题。我有一个简单易读的格式化代码:
但是,如果我按下代码 - 重新格式化代码,我的字符串声明会变得完全混乱:
如果只删除换行符号,那么这不会有问题,但代码 - 重新格式代码也会拆分我的字符串并进行空行插入(WTF)
在重新格式化之前比较字符串:
private static final String
DATABASE_CREATE =
"create table "
+ TABLE_NAME + "("
+ COLUMN_ID + " integer primary key autoincrement, "
+ COLUMN_ITEM_ID + " integer default '0', "
+ COLUMN_SLUG + " text default '',"
+ COLUMN_TITLE + " text default '',"
+ COLUMN_TYPE + " integer default '0', "
+ COLUMN_YOUTUBE_ID + " text default '',"
+ COLUMN_ARTISTS + " text default '',"
+ COLUMN_ARTISTS_SLUG + " text default '',"
+ COLUMN_DESCRIPTION + " text default '',"
+ COLUMN_PICTURE + " text default '',"
+ COLUMN_SOURCE + " text default '',"
+ COLUMN_VIEW_COUNT + " integer '0',"
+ COLUMN_GOOGLE_LINK + " text default '',"
+ COLUMN_OFFLINE_SOURCE + " text default '',"
+ COLUMN_IS_SAVED_OFFLINE + " integer '0', "
+ COLUMN_OFFLINE_PLAYS + " integer default '0',"
+ COLUMN_DOWNLOADING_ID + " integer default '-1',"
+ COLUMN_IS_LIKE + " integer default '0' " +
");";
重新格式化后和字符串:
private static final String
DATABASE_CREATE =
"create table " + TABLE_NAME + "(" + COLUMN_ID + " integer primary key autoincrement, " +
"" + COLUMN_ITEM_ID + " integer default '0', " + COLUMN_SLUG + " text " +
"default ''," + COLUMN_TITLE + " text default ''," + COLUMN_TYPE + " integer " +
"default '0', " + COLUMN_YOUTUBE_ID + " text default ''," +
"" + COLUMN_ARTISTS + " text default ''," + COLUMN_ARTISTS_SLUG + " text " +
"default ''," + COLUMN_DESCRIPTION + " text default ''," +
"" + COLUMN_PICTURE + " text default ''," + COLUMN_SOURCE + " text default " +
"''," + COLUMN_VIEW_COUNT + " integer '0'," + COLUMN_GOOGLE_LINK + " text " +
"default ''," + COLUMN_OFFLINE_SOURCE + " text default ''," +
"" + COLUMN_IS_SAVED_OFFLINE + " integer '0', " + COLUMN_OFFLINE_PLAYS + " " +
"integer default '0'," + COLUMN_DOWNLOADING_ID + " integer default '-1'," +
"" + COLUMN_IS_LIKE + " integer default '0' " +
");";
你显然可以看到之前没有的""
。
如何解决这种奇怪的行为?