- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经尝试了这里关于“android.database.sqlite.SQLiteException”的所有各种建议。我仍然不断收到错误。每次我尝试运行该应用程序时,它都会崩溃,这是由该异常引起的。我已经将每一行读了大约 10 遍,但仍然找不到错误。请帮忙,我将非常感激。
EventHandler类
package com.team11.healthdb;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class EventHandler extends SQLiteOpenHelper {
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "HealthTracker";
public EventHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// Creating Tables
@Override
public void onCreate(SQLiteDatabase db) {
//SQL Statement to create TABLE_EVENTS
String CREATE_TABLE_EVENTS = "CREATE TABLE TABLE_EVENTS ( "
+ "KEY_ID INTEGER PRIMARY KEY AUTOINCREMENT, "
+ "KEY_TITLE TEXT, " + "KEY_DESCRIPTION TEXT, "
+ "KEY_START INTEGER, " + "KEY_END INTEGER, "
+ "KEY_LOCATION TEXT )";
// Creates TABLE_EVENTS
db.execSQL(CREATE_TABLE_EVENTS);
}
// Upgrading database
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS TABLE_EVENTS");
// Creates fresh table
this.onCreate(db);
}
//-------------------------------------------------------------------------
/**
* All CRUD(Create, Read, Update, Delete) Operations
*/
// Events table name
private static final String TABLE_EVENTS = "EVENTS";
// Events Table Columns names
private static final String KEY_ID = "ID";
private static final String KEY_TITLE = "Title";
private static final String KEY_DESCRIPTION = "Description";
private static final String KEY_START = "Start Time";
private static final String KEY_END = "End Time";
private static final String KEY_LOCATION = "Location";
private static final String[] COLUMNS = {KEY_ID,KEY_TITLE,KEY_DESCRIPTION,KEY_START,KEY_END,KEY_LOCATION};
// Adding new contact
public void addEvent(Event event) {
Log.d("addEvent", event.toString());
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_TITLE, event.getTitle()); // Event Title
values.put(KEY_DESCRIPTION, event.getDescription()); // Event Description
values.put(KEY_START, event.getStart()); // Event Start Time
values.put(KEY_END, event.getEnd()); // Event End Time
values.put(KEY_LOCATION, event.getLocation()); // Event Location
// Inserting Row
db.insert(TABLE_EVENTS, null, values);
db.close(); // Closing database connection
}
// Getting single event
public Event getEvent(int id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_EVENTS, COLUMNS, " KEY_ID = ?",
new String[] { String.valueOf(id) }, null, null, null, null);
if (cursor != null)
cursor.moveToFirst();
Event event = new Event();
event.setID(Integer.parseInt(cursor.getString(0)));
event.setTitle(cursor.getString(1));
event.setDescription(cursor.getString(2));
event.setStart(Integer.parseInt(cursor.getString(3)));
event.setEnd(Integer.parseInt(cursor.getString(4)));
event.setLocation(cursor.getString(5));
//log
Log.d("getEvent("+id+")", event.toString());
// return contact
return event;
}
// Getting All Events
public List<Event> getAllEvents() {
List<Event> events = new ArrayList<Event>();
// Select All Query
String query = "SELECT * FROM " + TABLE_EVENTS;
// Get reference to writable DB
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null);
// Go over each row, build book and add it to list
Event event = null;
if (cursor.moveToFirst()) {
do {
event = new Event();
event.setID(Integer.parseInt(cursor.getString(0)));
event.setTitle(cursor.getString(1));
event.setDescription(cursor.getString(2));
event.setStart(Integer.parseInt(cursor.getString(3)));
event.setEnd(Integer.parseInt(cursor.getString(4)));
event.setLocation(cursor.getString(5));
// Adding events to list
events.add(event);
} while (cursor.moveToNext());
}
Log.d("getAllEvents()", events.toString());
// return contact list
return events;
}
// Updating single contact
public int updateEvent(Event event) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put("KEY_TITLE", event.getTitle()); // Event Title
values.put("KEY_DESCRIPTION", event.getDescription()); // Event Description
values.put("KEY_START", event.getStart()); // Event Start Time
values.put("KEY_END", event.getEnd()); // Event End Time
values.put("KEY_LOCATION", event.getLocation()); // Event Location
// updating row
int i = db.update(TABLE_EVENTS, values, KEY_ID + " = ?",
new String[] { String.valueOf(event.getID()) });
// Close DB
db.close();
return i;
}
// Deleting single event
public void deleteEvent(Event event) {
SQLiteDatabase db = this.getWritableDatabase();
// Delete
db.delete(TABLE_EVENTS, KEY_ID + " = ?",
new String[] { String.valueOf(event.getID()) });
// Close
db.close();
Log.d("deleteEvent", event.toString());
}
}
MainActivity 类
package com.team11.healthdb;
import java.util.List;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EventHandler db = new EventHandler(this);
/**
* CRUD Operations
* */
// Inserting Contacts
Log.d("Insert: ", "Inserting ..");
db.addEvent(new Event("Headache", "Took Medicine and had side effects", 1015, 1018, "Bedroom"));
db.addEvent(new Event("Dizzy", "Took Medicine and had side effects", 1520, 1530, "Asda"));
db.addEvent(new Event("Blackouts", "Took Medicine and had side effects", 1015, 1018, "Tesco"));
// get all books
List<Event> list = db.getAllEvents();
// delete one book
db.deleteEvent(list.get(0));
// get all books
db.getAllEvents();
}
}
这是错误日志:
11-03 17:05:39.434: I/dalvikvm(1195): Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted
11-03 17:05:39.434: W/dalvikvm(1195): VFY: unable to resolve virtual method 11388: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V
11-03 17:05:39.444: D/dalvikvm(1195): VFY: replacing opcode 0x6f at 0x0000
11-03 17:05:39.444: I/dalvikvm(1195): Could not find method android.view.ViewGroup.onStopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onStopNestedScroll
11-03 17:05:39.444: W/dalvikvm(1195): VFY: unable to resolve virtual method 11394: Landroid/view/ViewGroup;.onStopNestedScroll (Landroid/view/View;)V
11-03 17:05:39.444: D/dalvikvm(1195): VFY: replacing opcode 0x6f at 0x0000
11-03 17:05:39.474: I/dalvikvm(1195): Could not find method android.support.v7.internal.widget.ActionBarOverlayLayout.stopNestedScroll, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.setHideOnContentScrollEnabled
11-03 17:05:39.474: W/dalvikvm(1195): VFY: unable to resolve virtual method 8967: Landroid/support/v7/internal/widget/ActionBarOverlayLayout;.stopNestedScroll ()V
11-03 17:05:39.484: D/dalvikvm(1195): VFY: replacing opcode 0x6e at 0x000e
11-03 17:05:39.534: I/dalvikvm(1195): Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
11-03 17:05:39.544: W/dalvikvm(1195): VFY: unable to resolve virtual method 367: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
11-03 17:05:39.544: D/dalvikvm(1195): VFY: replacing opcode 0x6e at 0x0002
11-03 17:05:39.564: I/dalvikvm(1195): Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
11-03 17:05:39.574: W/dalvikvm(1195): VFY: unable to resolve virtual method 389: Landroid/content/res/TypedArray;.getType (I)I
11-03 17:05:39.574: D/dalvikvm(1195): VFY: replacing opcode 0x6e at 0x0002
11-03 17:05:39.874: D/Insert:(1195): Inserting ..
11-03 17:05:39.874: D/addEvent(1195): Event [Event ID: 0, Event Title: Headache, Event Description: Took Medicine and had side effects, Start Time: 1015, End Time: 1018, Location: Bedroom]
11-03 17:05:40.114: E/SQLiteLog(1195): (1) near "Time": syntax error
11-03 17:05:40.154: E/SQLiteDatabase(1195): Error inserting End Time=1018 Start Time=1015 Location=Bedroom Description=Took Medicine and had side effects Title=Headache
11-03 17:05:40.154: E/SQLiteDatabase(1195): android.database.sqlite.SQLiteException: near "Time": syntax error (code 1): , while compiling: INSERT INTO EVENTS(End Time,Start Time,Location,Description,Title) VALUES (?,?,?,?,?)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1467)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at com.team11.healthdb.EventHandler.addEvent(EventHandler.java:79)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at com.team11.healthdb.MainActivity.onCreate(MainActivity.java:21)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.app.Activity.performCreate(Activity.java:5231)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.app.ActivityThread.access$800(ActivityThread.java:135)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.os.Handler.dispatchMessage(Handler.java:102)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.os.Looper.loop(Looper.java:136)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at android.app.ActivityThread.main(ActivityThread.java:5017)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at java.lang.reflect.Method.invokeNative(Native Method)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at java.lang.reflect.Method.invoke(Method.java:515)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
11-03 17:05:40.154: E/SQLiteDatabase(1195): at dalvik.system.NativeStart.main(Native Method)
11-03 17:05:40.164: D/addEvent(1195): Event [Event ID: 0, Event Title: Dizzy, Event Description: Took Medicine and had side effects, Start Time: 1520, End Time: 1530, Location: Asda]
11-03 17:05:40.264: E/SQLiteLog(1195): (1) near "Time": syntax error
11-03 17:05:40.294: E/SQLiteDatabase(1195): Error inserting End Time=1530 Start Time=1520 Location=Asda Description=Took Medicine and had side effects Title=Dizzy
11-03 17:05:40.294: E/SQLiteDatabase(1195): android.database.sqlite.SQLiteException: near "Time": syntax error (code 1): , while compiling: INSERT INTO EVENTS(End Time,Start Time,Location,Description,Title) VALUES (?,?,?,?,?)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1467)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at com.team11.healthdb.EventHandler.addEvent(EventHandler.java:79)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at com.team11.healthdb.MainActivity.onCreate(MainActivity.java:22)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.app.Activity.performCreate(Activity.java:5231)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.app.ActivityThread.access$800(ActivityThread.java:135)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.os.Handler.dispatchMessage(Handler.java:102)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.os.Looper.loop(Looper.java:136)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at android.app.ActivityThread.main(ActivityThread.java:5017)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at java.lang.reflect.Method.invokeNative(Native Method)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at java.lang.reflect.Method.invoke(Method.java:515)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
11-03 17:05:40.294: E/SQLiteDatabase(1195): at dalvik.system.NativeStart.main(Native Method)
11-03 17:05:40.294: D/addEvent(1195): Event [Event ID: 0, Event Title: Blackouts, Event Description: Took Medicine and had side effects, Start Time: 1015, End Time: 1018, Location: Tesco]
11-03 17:05:40.354: E/SQLiteLog(1195): (1) near "Time": syntax error
11-03 17:05:40.404: E/SQLiteDatabase(1195): Error inserting End Time=1018 Start Time=1015 Location=Tesco Description=Took Medicine and had side effects Title=Blackouts
11-03 17:05:40.404: E/SQLiteDatabase(1195): android.database.sqlite.SQLiteException: near "Time": syntax error (code 1): , while compiling: INSERT INTO EVENTS(End Time,Start Time,Location,Description,Title) VALUES (?,?,?,?,?)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1467)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at com.team11.healthdb.EventHandler.addEvent(EventHandler.java:79)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at com.team11.healthdb.MainActivity.onCreate(MainActivity.java:23)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.app.Activity.performCreate(Activity.java:5231)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.app.ActivityThread.access$800(ActivityThread.java:135)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.os.Handler.dispatchMessage(Handler.java:102)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.os.Looper.loop(Looper.java:136)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at android.app.ActivityThread.main(ActivityThread.java:5017)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at java.lang.reflect.Method.invokeNative(Native Method)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at java.lang.reflect.Method.invoke(Method.java:515)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
11-03 17:05:40.404: E/SQLiteDatabase(1195): at dalvik.system.NativeStart.main(Native Method)
11-03 17:05:40.524: E/SQLiteLog(1195): (1) no such table: EVENTS
11-03 17:05:40.544: D/AndroidRuntime(1195): Shutting down VM
11-03 17:05:40.544: W/dalvikvm(1195): threadid=1: thread exiting with uncaught exception (group=0xb3a97ba8)
11-03 17:05:40.644: E/AndroidRuntime(1195): FATAL EXCEPTION: main
11-03 17:05:40.644: E/AndroidRuntime(1195): Process: com.team11.healthdb, PID: 1195
11-03 17:05:40.644: E/AndroidRuntime(1195): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.team11.healthdb/com.team11.healthdb.MainActivity}: android.database.sqlite.SQLiteException: no such table: EVENTS (code 1): , while compiling: SELECT * FROM EVENTS
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.app.ActivityThread.access$800(ActivityThread.java:135)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.os.Handler.dispatchMessage(Handler.java:102)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.os.Looper.loop(Looper.java:136)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.app.ActivityThread.main(ActivityThread.java:5017)
11-03 17:05:40.644: E/AndroidRuntime(1195): at java.lang.reflect.Method.invokeNative(Native Method)
11-03 17:05:40.644: E/AndroidRuntime(1195): at java.lang.reflect.Method.invoke(Method.java:515)
11-03 17:05:40.644: E/AndroidRuntime(1195): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
11-03 17:05:40.644: E/AndroidRuntime(1195): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
11-03 17:05:40.644: E/AndroidRuntime(1195): at dalvik.system.NativeStart.main(Native Method)
11-03 17:05:40.644: E/AndroidRuntime(1195): Caused by: android.database.sqlite.SQLiteException: no such table: EVENTS (code 1): , while compiling: SELECT * FROM EVENTS
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
11-03 17:05:40.644: E/AndroidRuntime(1195): at com.team11.healthdb.EventHandler.getAllEvents(EventHandler.java:116)
11-03 17:05:40.644: E/AndroidRuntime(1195): at com.team11.healthdb.MainActivity.onCreate(MainActivity.java:26)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.app.Activity.performCreate(Activity.java:5231)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
11-03 17:05:40.644: E/AndroidRuntime(1195): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
11-03 17:05:40.644: E/AndroidRuntime(1195): ... 11 more
最佳答案
避免字段名称中出现空格。改变你的台词
private static final String KEY_START = "Start Time";
private static final String KEY_END = "End Time";
由
private static final String KEY_START = "Start_Time";
private static final String KEY_END = "End_Time";
线路
11-03 17:05:40.154: E/SQLiteDatabase(1195): android.database.sqlite.SQLiteException: near "Time": syntax error (code 1): , while compiling: INSERT INTO EVENTS(End Time,Start Time,Location,Description,Title) VALUES (?,?,?,?,?)
通常是了解所发生情况的关键。
关于javascript - 总是收到 android.database.sqlite.SQLiteException : near "Time" when running SQLite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26724417/
我正在开发一个 SQLite 数据库。数据库已经填满了,但我想重构它。这是我需要做的一个示例: 我目前有一张 table : CREATE TABLE Cars (ID INTEGER PRIMARY
我正在使用 Mono、SQLite、Dapper 和 Dapper 扩展。我可以从数据库中读取数据,但插入不起作用。我正在使用 sqlite 的 Mono 驱动程序。 错误并不能提供太多信息,至少对我
我有一个使用 SQLite 的 Windows Phone 8 应用程序。该应用程序具有许多数据库功能,并包含一个 sqlite 数据库文件,在运行该应用程序时,该文件将被复制到本地文件夹并进行访问。
为 sqlite 创建索引时有排序顺序。 https://sqlite.org/lang_createindex.html Each column name or expression can be
顾名思义,我怀疑如果有一些引用被删除的表会发生什么,例如表的某些字段的索引。 SQLite是否会自动处理?在执行drop命令之前,数据库所有者是否应注意任何实例? 最佳答案 我认为不需要家政服务。 S
我想知道是否有可能将从计数中获得的整数转换为REAL 类似于以下内容(尽管这不起作用) SELECT CAST (COUNT (ColumnA) AS Count) AS REAL) FROM Tab
我无法在SQLite数据库上执行一些更新。我正在Windows上使用SQLite 3 Shell。 我正在运行以下命令: update resovled_chrom_counts set genus
我知道SQLite中的触发器顺序是不确定的(您不能确定将首先执行哪个触发器),但是表约束和触发器之间的关系又如何呢? 我的意思是,假设我在一个列中有一个UNIQUE(或CHECK)约束,并且在该表上有
我的 CustomTags 表可能有一系列“临时”记录,其中 Tag_ID 为 0,并且 Tag_Number 将有一些五位数的值。 定期,我想清理我的 Sqlite 表以删除这些临时值。 例如,我可
我有A,B,C和D的记录。 我的SQL1 SELECT * FROM main_table order by main_table.date desc limit 2返回A和B。 我的SQL2 SEL
select round(836.0)返回836.0 我如何删除sqlite查询中的尾随零。 836.00应该是836 836.440应该是836.44 最佳答案 如果需要836.44,则需要十进制返
我正在研究RQDA中的文本,并且正在使用Firefox SQLite Manager访问数据库,以便可以更轻松地搜索文件。我创建并填充了虚拟表: CREATE VIRTUAL TABLE texts
我有这样的数据: table1 id | part | price 1 | ox900 | 100 2 | ox980 | 200 和 table2 id | part | price 1
我正在尝试将一些数据插入现有的SQLite表中。该表和数据库是使用相同的API创建的,但是由于某种原因,插入操作无效,并且从不给我任何错误消息。 我正在BlackBerry 9550模拟器上对此进行测
例如,我在名为SALARY的列中插入一个值。如果插入的值大于1000,我想将字符串HIGH插入到RANK列中,否则将插入LOW中。 我可以使用SQLite做到吗? 最佳答案 在插入之前使用触发器,然后
假设我有一个包含三列A,B,C的表t1,其中(A,B)包含唯一键(具有数十万行)。由于90%的查询将采用SELECT C FROM t1 WHERE A =?和B = ?,我想我要为A,B和C提供覆盖
在一个SQLite3数据库中,我有一个表“ projects”,其id字段由以下方式组成: [user id]_[user's project id] 例如,用户ID = 45,这是一些数据: 45_
我了解PRAGMA foreign_key和ON DELETE RESTRICT/NO ACTION的概念,但是我面临的是另一种情况。 我需要删除一个父行,但保持与之关联的子行。例如: CREATE
我的c#应用程序从Web服务1读取文件列表,并将完整的文件名插入table1,然后从第二个Web服务读取list并将它们插入到table2。 这些表具有相同的结构,如下所示: create table
我在以下情况下尝试将Record1的ID更新为Record2的ID: 两个表中的名称相同,并且 在Record2中权重更大。 记录1 | ID | Weight | Name | |----|----
我是一名优秀的程序员,十分优秀!