我开发了一个使用 sqlite 数据库的 android 应用程序。
- 主要问题: *我一直面临这个错误,没有这样的专栏,但我只是找不到这个问题的原因。任何意见将不胜感激。*
次要问题: 我希望应用程序检查用户的信息是否在数据库中。如果它不存在,我希望系统能够处理某些事情。检查部分怎么做?我尝试了类似下面的方法。但我不确定它是否有效,因为没有这样的专栏问题。
String values[] = helper.get_synccontentByEmailID(SettingConstant.EMAIL); if(!(values[0] == null)){ }
--数据库类--
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE synccontent (" +
"tableid INTEGER PRIMARY KEY AUTOINCREMENT, " +
"emailid_sync TEXT " +
"contentid TEXT," +
"contentpath TEXT," +
"filesize TEXT," +
"createdtime TEXT,"+
"createdate TIMESTAMP default current_timestamp);");
}
public String[] get_synccontentByEmailID(String emailid_sync){
SQLiteDatabase myDB = null;
String[] returnMsg = null;
myDB = this.getReadableDatabase();
Cursor c = myDB.rawQuery("SELECT tableid, emailid_sync, contentid, contentpath, filesize, createdtime" +
" from synccontent where emailid_sync='"+emailid_sync+"' ", null);
int emailid_syncColumn = c.getColumnIndex("emailid_sync");
int contentidColumn = c.getColumnIndex("contentid");
int contentpathColumn = c.getColumnIndex("contentpath");
int filesizeColumn = c.getColumnIndex("filesize");
int createdtimeColumn = c.getColumnIndex("createdtime");
if (c.moveToFirst()) {
do {
returnMsg = new String[5];
String contentid = c.getString(contentidColumn);
String contentpath = c.getString(contentpathColumn);
String filesize = c.getString(filesizeColumn);
String createdtime = c.getString(createdtimeColumn);
returnMsg[0] = emailid_sync;
returnMsg[1] = contentid;
returnMsg[2] = contentpath;
returnMsg[3] = filesize;
returnMsg[4] = createdtime;
} while (c.moveToNext());
}
- 主要活动 -
syncButton = (Button) findViewById(R.id.sync_btn);
syncButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
String values[] = helper.get_synccontentByEmailID(SettingConstant.EMAIL);
if(!(values[0] == null)){
}
E/AndroidRuntime(4543): android.database.sqlite.SQLiteException: no such column: contentid: , while compiling: SELECT tableid, emailid_sync, contentid, contentpath, filesize, createdtime from wbm_synccontent where emailid_sync='testing@yahoo.com'