Android SQLite错误我可以';不要重现
我在android market上报告了一个错误,我无法重新创建。错误是Android SQLite错误我可以';不要重现,android,sqlite,Android,Sqlite,我在android market上报告了一个错误,我无法重新创建。错误是 Caused by: android.database.sqlite.SQLiteException: near ".": syntax error: , while compiling: SELECT _id, Song, Number FROM HOLA. at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) at andr
Caused by: android.database.sqlite.SQLiteException: near ".": syntax error: , while compiling: SELECT _id, Song, Number FROM HOLA.
at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1454)
at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1338)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1293)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1373)
at com.example.program.DBase.fetchData(DBase.java:89)
at com.example.program.View.fillData(View.java:57)
at com.example.program.View.onCreate(View.java:29)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more
及
最后
public Cursor fetchData(String loc) {
// TODO Auto-generated method stub
return ourDatabase.query(loc, new String[] { KEY_ROWID, KEY_ONE, KEY_TWO },
null, null, null, null, null);
}
loc是指向当前表的变量。你知道为什么会这样吗?我尝试输入数据,包括一个。和a,在错误中提到,但我无法获得FC
编辑添加我的添加表代码
public long addTable(String loc) {
// TODO Auto-generated method stub
ourDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + loc + " ("
+ KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_2TBL
+ " TEXT NOT NULL, " + KEY_TWO + " TEXT NOT NULL, "
+ KEY_ONE + " TEXT NOT NULL);");
ContentValues cv = new ContentValues();
cv.put(KEY_2TBL, loc);
return ourDatabase.insert(loc, null, cv);
}
我认为用户输入的是“HOLA”(带点),而不仅仅是“HOLA”。这可能就是应用程序给FC的原因我注意到我有大约40%的外语下载。从表名HOLA,我猜用户使用的是西班牙语。我的应用程序未本地化。这可能是个问题吗?就是这样!你知道如何防止用户在表名中输入不允许的字符吗?用户输入的表存储歌曲列表的“位置”。编辑我的帖子以包含我的添加表代码。您可以向文本框添加LoginFilter,并实现isallowed函数,在该函数中,您只能对允许的字符返回true
public Cursor fetchData(String loc) {
// TODO Auto-generated method stub
return ourDatabase.query(loc, new String[] { KEY_ROWID, KEY_ONE, KEY_TWO },
null, null, null, null, null);
}
public long addTable(String loc) {
// TODO Auto-generated method stub
ourDatabase.execSQL("CREATE TABLE IF NOT EXISTS " + loc + " ("
+ KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_2TBL
+ " TEXT NOT NULL, " + KEY_TWO + " TEXT NOT NULL, "
+ KEY_ONE + " TEXT NOT NULL);");
ContentValues cv = new ContentValues();
cv.put(KEY_2TBL, loc);
return ourDatabase.insert(loc, null, cv);
}