我在Android市场上报告了一个我无法重新创建的错误。错误是
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
HOLA是用户输入的表格。我使用的代码是
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getLoc();
setContentView(R.layout.notepad_list);
db = new DBase(this);
db.open();
fillData();
db.close();
}
和
private void fillData() {
// Get all of the notes from the database and create the item list
Cursor c = db.fetchData(loc);
startManagingCursor(c);
String[] from = new String[] { DBase.KEY_ONE, DBase.KEY_TWO };
int[] to = new int[] { R.id.text1, R.id.text2 };
// Now create an array adapter and set it to display using our row
SimpleCursorAdapter notes = new SimpleCursorAdapter(this,
R.layout.notes_row, c, from, to);
setListAdapter(notes);
}
最后
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);
}
答案 0 :(得分:1)
我认为用户已输入“HOLA。”(带点)而非“HOLA”。这可能是app给FC的原因