应用程序已停止android模拟器genymotion

时间:2015-12-19 16:35:20

标签: java android sqlite

除了打开应用程序失败之外,使用sqlite创建表也失败了 我的DatabaseHelper.java是

package com.example.brian.fds;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
* Created by Brian on 2015/12/18.
*/
public class DatabaseHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "User.db";
public  static final String TABLE_NAME = "user_table";
public  static final String  COL_1  = "ID";
public  static final String  COL_2 = "NAME";
public  static final String  COL_3 = "ACCOUNT";
public  static final String  COL_4 = "PASSWORD";
public  static final String  COL_5 = "PHONENUMBER";
public  static final String  COL_6 = "ROOMNUMBER";
public  static final String  COL_7 = "STUDENTID";
public  static final String  COL_8 = "DEPARTMENT";


public DatabaseHelper(Context context) {
    super(context, DATABASE_NAME, null, 1);
    SQLiteDatabase db = this.getWritableDatabase();
}

@Override
public void onCreate(SQLiteDatabase db) {
    String SQL_String = "CREATE TABLE " + TABLE_NAME + "("
            +COL_1+"INTEGER PRIMARY KEY AUTOINCREMENT,"
            +COL_2+" TEXT, "
            +COL_3 +"VARCHAR(20),"
            +COL_5+" INTEGER ,"
            +COL_6+" INTEGER ,"
            +COL_7+"  INTEGER,"
            +COL_8+" TEXT"+")";
    db.execSQL(SQL_String);

}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.execSQL("DROP TABLE IF EXISTS"+ TABLE_NAME);
    onCreate(db);

}

public boolean insertData(String name, String account, String password, String phonenumber, String roomnumber, String studentId, String department) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues contentValues = new ContentValues();
    contentValues.put(COL_2,name);
    contentValues.put(COL_3,account);
    contentValues.put(COL_4,password);
    contentValues.put(COL_5,phonenumber);
    contentValues.put(COL_6, roomnumber);
    contentValues.put(COL_7,studentId);
    contentValues.put(COL_8,department);
    long result = db.insert(TABLE_NAME, null, contentValues);
    if (result == -1)
        return false;
    else
        return true;
}

}

我的MainActivity.java是

package com.example.brian.fds;

import android.app.Activity;


import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


public class RPMainActivity extends Activity {
DatabaseHelper myDb;
EditText editName,editAccount,editPassWord,editPhoneNumber,editRoomNumber,editStudentID,editDepartment;
Button btnSend;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_rpmain);
    myDb = new DatabaseHelper(this);

    editName = (EditText)findViewById(R.id.Name);
    editAccount =  (EditText)findViewById(R.id.Account);
    editPassWord= (EditText)findViewById(R.id.Password);
    editPhoneNumber = (EditText)findViewById(R.id.PhoneNumber);
    editRoomNumber = (EditText)findViewById(R.id.RoomNumber);
    editStudentID = (EditText)findViewById(R.id.StudentID);
    editDepartment =  (EditText)findViewById(R.id.Department);
    btnSend = (Button)findViewById(R.id.Send);
    AddData();
}
public void AddData() {
    btnSend.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            boolean isInserted = myDb.insertData(editName.getText().toString(), editAccount.getText().toString(), editPassWord.getText().toString(),
                    editPhoneNumber.getText().toString(), editRoomNumber.getText().toString(), editStudentID.getText().toString(), editDepartment.getText().toString());
            if (isInserted = true)

                Toast.makeText(RPMainActivity.this, "isInserted success", Toast.LENGTH_LONG).show();
            else
                Toast.makeText(RPMainActivity.this, " Inserted defeat", Toast.LENGTH_LONG).show();
        }



    }
    );
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_rpmain, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

}

我的activity_rpmain.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".RPMainActivity"
android:orientation="vertical"
android:weightSum="1"
android:id="@+id/FDS">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="姓名:"
    android:id="@+id/textView"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="密碼:"
    android:id="@+id/textView2"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/textView3"
    android:layout_alignParentLeft="true"
    android:layout_marginTop="30dp" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="帳號:"
    android:id="@+id/textView3"
    android:layout_marginTop="30dp"
    android:layout_below="@+id/textView"
    android:layout_alignParentStart="true" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="手機:"
    android:id="@+id/textView4"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/textView2"
    android:layout_alignParentLeft="true"
    android:layout_marginTop="30dp" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="房號:"
    android:id="@+id/textView5"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/textView4"
    android:layout_alignParentLeft="true"
    android:layout_marginTop="30dp" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="學號:"
    android:id="@+id/textView6"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/textView5"
    android:layout_alignParentLeft="true"
    android:layout_marginTop="30dp" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:text="系級:"
    android:id="@+id/textView7"
    android:layout_alignParentStart="true"
    android:layout_below="@+id/textView6"
    android:layout_alignParentLeft="true"
    android:layout_marginTop="30dp" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/Name"
    android:layout_alignParentTop="true"
    android:layout_alignParentEnd="true"
    android:layout_toEndOf="@+id/textView"
    android:singleLine="true" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/Account"
    android:layout_below="@+id/Name"
    android:layout_alignEnd="@+id/Name"
    android:layout_toEndOf="@+id/textView3"
    android:singleLine="true" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textPassword"
    android:ems="10"
    android:id="@+id/Password"
    android:layout_alignTop="@+id/textView2"
    android:layout_alignEnd="@+id/Account"
    android:layout_toEndOf="@+id/textView2"
    android:singleLine="true" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="送出"
    android:id="@+id/Send"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="phone"
    android:ems="10"
    android:id="@+id/PhoneNumber"
    android:layout_alignTop="@+id/textView4"
    android:layout_alignEnd="@+id/Password"
    android:layout_toEndOf="@+id/textView4"
    android:singleLine="true" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/RoomNumber"
    android:layout_alignTop="@+id/textView5"
    android:layout_alignEnd="@+id/PhoneNumber"
    android:layout_toEndOf="@+id/textView5"
    android:singleLine="true" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/StudentID"
    android:layout_alignTop="@+id/textView6"
    android:layout_alignEnd="@+id/RoomNumber"
    android:layout_toEndOf="@+id/textView6"
    android:singleLine="true" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/Department"
    android:layout_below="@+id/StudentID"
    android:layout_alignEnd="@+id/StudentID"
    android:layout_toEndOf="@+id/textView7"
    android:singleLine="true" />

,日志是

    12-19 11:31:28.890    2060-2060/? D/AndroidRuntime﹕ >>>>>> START       com.android.internal.os.RuntimeInit uid 0 <<<<<<
    12-19 11:31:28.892    2060-2060/? D/AndroidRuntime﹕ CheckJNI is OFF
    12-19 11:31:28.906    2060-2060/? D/ICU﹕ No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
    12-19 11:31:28.923    2060-2060/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
    12-19 11:31:28.923    2060-2060/? E/android.os.Debug﹕ failed to load memtrack module: -2
12-19 11:31:28.925    2060-2060/? I/Radio-JNI﹕ register_android_hardware_Radio DONE
12-19 11:31:28.937    2060-2060/? D/AndroidRuntime﹕ Calling main entry com.android.commands.am.Am
    --------- beginning of system
12-19 11:31:28.943      623-772/? I/ActivityManager﹕ Force stopping com.example.brian.fds appid=10059 user=0: from pid 2060
12-19 11:31:28.948    1001-1001/? E/ActivityThread﹕ Performing pause of activity that is not resumed: {com.android.launcher3/com.android.launcher3.Launcher}
    java.lang.RuntimeException: Performing pause of activity that is not resumed: {com.android.launcher3/com.android.launcher3.Launcher}
            at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3352)
            at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3340)
            at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3315)
            at android.app.ActivityThread.-wrap13(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-19 11:31:28.952    2060-2060/? D/AndroidRuntime﹕ Shutting down VM
12-19 11:31:29.774    2071-2071/? D/AndroidRuntime﹕ >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
12-19 11:31:29.776    2071-2071/? D/AndroidRuntime﹕ CheckJNI is OFF
12-19 11:31:29.789    2071-2071/? D/ICU﹕ No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
12-19 11:31:29.808    2071-2071/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
12-19 11:31:29.808    2071-2071/? E/android.os.Debug﹕ failed to load memtrack module: -2
12-19 11:31:29.809    2071-2071/? I/Radio-JNI﹕ register_android_hardware_Radio DONE
12-19 11:31:29.818    2071-2071/? D/AndroidRuntime﹕ Calling main entry com.android.commands.am.Am
12-19 11:31:29.827      623-634/? I/ActivityManager﹕ START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.brian.fds/.RPMainActivity} from uid 0 on display 0
12-19 11:31:29.841    1001-1001/? E/ActivityThread﹕ Performing pause of activity that is not resumed: {com.android.launcher3/com.android.launcher3.Launcher}
    java.lang.RuntimeException: Performing pause of activity that is not resumed: {com.android.launcher3/com.android.launcher3.Launcher}
            at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3352)
            at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3340)
            at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3315)
            at android.app.ActivityThread.-wrap13(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-19 11:31:29.844    2071-2071/? D/AndroidRuntime﹕ Shutting down VM
12-19 11:31:29.852    2079-2079/? I/art﹕ Late-enabling -Xcheck:jni
12-19 11:31:29.855      623-635/? I/ActivityManager﹕ Start proc 2079:com.example.brian.fds/u0a59 for activity com.example.brian.fds/.RPMainActivity
12-19 11:31:29.879    1001-1001/? W/ViewRootImpl﹕ Cancelling event due to no window focus: KeyEvent { action=ACTION_UP, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x28, repeatCount=0, eventTime=3759884, downTime=551480, deviceId=1, source=0x301 }
12-19 11:31:29.879    1001-1001/? W/ViewRootImpl﹕ Cancelling event due to no window focus: KeyEvent { action=ACTION_UP, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x28, repeatCount=0, eventTime=3759884, downTime=551480, deviceId=1, source=0x301 }
12-19 11:31:29.879    1001-1001/? W/ViewRootImpl﹕ Cancelling event due to no window focus: KeyEvent { action=ACTION_UP, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x28, repeatCount=0, eventTime=3759884, downTime=551480, deviceId=1, source=0x301 }
12-19 11:31:29.879    1001-1001/? W/ViewRootImpl﹕ Cancelling event due to no window focus: KeyEvent { action=ACTION_UP, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x28, repeatCount=0, eventTime=3759884, downTime=551480, deviceId=1, source=0x301 }
12-19 11:31:29.879    1001-1001/? W/ViewRootImpl﹕ Cancelling event due to no window focus: KeyEvent { action=ACTION_UP, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x28, repeatCount=0, eventTime=3759884, downTime=551480, deviceId=1, source=0x301 }
12-19 11:31:29.879    1001-1001/? W/ViewRootImpl﹕ Cancelling event due to no window focus: KeyEvent { action=ACTION_UP, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x28, repeatCount=0, eventTime=3759884, downTime=551480, deviceId=1, source=0x301 }
12-19 11:31:29.892    2079-2079/? W/System﹕ ClassLoader referenced unknown path: /data/app/com.example.brian.fds-2/lib/x86
12-19 11:31:29.921    2079-2079/? E/SQLiteLog﹕ (1) AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY
12-19 11:31:29.922    2079-2079/? D/AndroidRuntime﹕ Shutting down VM
    --------- beginning of crash
12-19 11:31:29.922    2079-2079/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.brian.fds, PID: 2079
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.brian.fds/com.example.brian.fds.RPMainActivity}: android.database.sqlite.SQLiteException: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY (code 1): , while compiling: CREATE TABLE user_table(IDINTEGER PRIMARY KEY AUTOINCREMENT,NAME TEXT, ACCOUNTVARCHAR(20),PHONENUMBER INTEGER ,ROOMNUMBER INTEGER ,STUDENTID  INTEGER,DEPARTMENT TEXT)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: android.database.sqlite.SQLiteException: AUTOINCREMENT is only allowed on an INTEGER PRIMARY KEY (code 1): , while compiling: CREATE TABLE user_table(IDINTEGER PRIMARY KEY AUTOINCREMENT,NAME TEXT, ACCOUNTVARCHAR(20),PHONENUMBER INTEGER ,ROOMNUMBER INTEGER ,STUDENTID  INTEGER,DEPARTMENT TEXT)
            at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
            at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
            at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
            at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
            at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
            at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
            at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1674)
            at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1605)
            at com.example.brian.fds.DatabaseHelper.onCreate(DatabaseHelper.java:39)
            at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
            at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
            at com.example.brian.fds.DatabaseHelper.<init>(DatabaseHelper.java:26)
            at com.example.brian.fds.RPMainActivity.onCreate(RPMainActivity.java:25)
            at android.app.Activity.performCreate(Activity.java:6237)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-19 11:31:29.925     623-1830/? W/ActivityManager﹕ Force finishing activity com.example.brian.fds/.RPMainActivity
12-19 11:31:30.244     623-1830/? I/WindowManager﹕ Screenshot max retries 4 of Token{175d2 ActivityRecord{4f4e85d u0 com.example.brian.fds/.RPMainActivity t60 f}} appWin=Window{265a2cd u0 Starting com.example.brian.fds} drawState=1
12-19 11:31:30.281      623-643/? W/ViewRootImpl﹕ Dropping event due to no window focus: KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x8, repeatCount=62265, eventTime=3759883, downTime=551480, deviceId=1, source=0x301 }
12-19 11:31:30.286      623-643/? W/ViewRootImpl﹕ Dropping event due to no window focus: KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x8, repeatCount=62266, eventTime=3760322, downTime=551480, deviceId=1, source=0x301 }
12-19 11:31:30.329     623-1362/? I/OpenGLRenderer﹕ Initialized EGL, version 1.4
12-19 11:31:30.372     623-1362/? W/EGL_emulation﹕ eglSurfaceAttrib not implemented
12-19 11:31:30.372     623-1362/? W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xd9ba0860, error=EGL_SUCCESS
12-19 11:31:30.412      623-643/? W/ViewRootImpl﹕ Dropping event due to no window focus: KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x8, repeatCount=62267, eventTime=3760374, downTime=551480, deviceId=1, source=0x301 }
12-19 11:31:30.638      623-643/? W/ViewRootImpl﹕ Dropping event due to no window focus: KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x8, repeatCount=62268, eventTime=3760425, downTime=551480, deviceId=1, source=0x301 }
12-19 11:31:30.746      623-641/? W/ActivityManager﹕ Activity pause timeout for ActivityRecord{4f4e85d u0 com.example.brian.fds/.RPMainActivity t60 f}
12-19 11:31:31.068      623-937/? W/art﹕ Long monitor contention event with owner method=void com.android.server.am.ActivityStack$ActivityStackHandler.handleMessage(android.os.Message) from ActivityStack.java:283 waiters=1 for 131ms
12-19 11:31:31.082      623-635/? I/ActivityManager﹕ Killing 1500:com.android.providers.calendar/u0a1 (adj 15): empty for 3694s
12-19 11:31:41.115      623-641/? W/ActivityManager﹕ Activity destroy timeout for ActivityRecord{4f4e85d u0 com.example.brian.fds/.RPMainActivity t60 f}
12-19 11:31:47.349    2079-2079/? I/Process﹕ Sending signal. PID: 2079 SIG: 9
12-19 11:31:47.350      317-687/? D/AudioFlinger﹕ mixer(0xf1e40000) throttle end: throttle time(11)
12-19 11:31:47.385     623-1832/? I/ActivityManager﹕ Process com.example.brian.fds (pid 2079) has died
12-19 11:31:47.442     623-1362/? E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xf2c364b0
12-19 11:31:47.456     623-1362/? D/OpenGLRenderer﹕ endAllStagingAnimators on 0xdae68d00 (RippleDrawable) with handle 0xdabd1f60
12-19 11:31:47.459    1001-1001/? W/ViewRootImpl﹕ Dropping event due to no window focus: KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x8, repeatCount=62593, eventTime=3777445, downTime=551480, deviceId=1, source=0x301 }
12-19 11:31:47.460    1001-1001/? W/ViewRootImpl﹕ Dropping event due to no window focus: KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_ALT_RIGHT, scanCode=100, metaState=META_ALT_ON|META_ALT_RIGHT_ON, flags=0x8, repeatCount=62594, eventTime=3777500, downTime=551480, deviceId=1, source=0x301 }
12-19 11:31:47.462     623-1008/? W/InputMethodManagerService﹕ Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@ed48c00 attribute=null, token = android.os.BinderProxy@fefde8e
12-19 11:31:47.706      623-648/? W/AppOps﹕ Finishing op nesting under-run: uid 1000 pkg android code 24 time=0 duration=0 nesting=0

plz ..解释为什么会这样..告诉我解决方案

1 个答案:

答案 0 :(得分:1)

来自您的日志:

  

引起:android.database.sqlite.SQLiteException:

     

只允许在INTEGER PRIMARY KEY

上使用AUTOINCREMENT

从你的代码:

@Override
public void onCreate(SQLiteDatabase db) {
    String SQL_String = "CREATE TABLE " + TABLE_NAME + "("
            +COL_1+"INTEGER PRIMARY KEY AUTOINCREMENT,"
            +COL_2+" TEXT, "
            +COL_3 +"VARCHAR(20),"

您的字符串缺少空格,因此语法无效,请尝试:

@Override
public void onCreate(SQLiteDatabase db) {
    String SQL_String = "CREATE TABLE " + TABLE_NAME + "("
            + COL_1 + " INTEGER PRIMARY KEY AUTOINCREMENT, "
            + COL_2 + " TEXT, "
            + COL_3 + " VARCHAR(20), "