【问题标题】:Error in Android Studio: illegal character:'\u2028'Android Studio 中的错误:非法字符:'\u2028'
【发布时间】:2019-05-24 10:57:18
【问题描述】:

出现此错误时,我正在编写 DatabaseHelper 代码。

public class DatabaseHelper extends SQLiteOpenHelper {

private static final String DB_NAME = "Items.db";
private static final String DB_TABLE = "Items_Table";

private static final String DB_TABLE1 = "Items_Table1";
private static final String NAME = "NAME";
private static final String ID = "ID";
private static final String ID1 = "ID1";
private static final String PLACE = "PLACE";



private static final String CREATE_TABLE = "CREATE TABLE " +      DB_TABLE + " (" + ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + NAME
        + " TEXT " + ")";
private static final String CREATE_TABLE1 = "CREATE TABLE " + DB_TABLE1 + " (" + ID1 + " INTEGER PRIMARY KEY AUTOINCREMENT, "+
        PLACE + " TEXT " + " , " + ID + " INTEGER REFERENCES " + DB_TABLE + ")";



public  DatabaseHelper(Context context)
{

    super(context,DB_NAME,null,1);
}

public void onConfigure(SQLiteDatabase db)
{
    super.onConfigure(db);
    db.setForeignKeyConstraintsEnabled(true);
}



public void onCreate(SQLiteDatabase db)
{
    db.execSQL(CREATE_TABLE);
    db.execSQL(CREATE_TABLE1);
}

我收到一个 Android Studio 错误:非法字符:'\u2028'。这是什么意思,我该如何纠正。

【问题讨论】:

标签: android unexpected-token


【解决方案1】:

这是换行符,如果您转到导致错误的每一行并删除“不可见”的最后一个字符,那么错误将解决

转到导致错误的行的末尾并按一次退格键,对于每个有非法字符错误的行

您也可以使用 Android Studio 的替换功能,在“替换为”中放入一个空字符串来代替这个非法字符。

【讨论】:

    猜你喜欢
    • 2016-04-07
    • 2015-08-23
    • 1970-01-01
    • 2011-02-27
    • 2015-05-09
    • 2015-08-28
    • 2012-03-02
    • 1970-01-01
    相关资源
    最近更新 更多