本帖最后由 sawq1111 于 2011-05-09 19:17:27 编辑

解决方案 »

  1.   

    05-10 14:24:38.309: ERROR/Zygote(32): setreuid() failed. errno: 2
    05-10 14:24:47.528: ERROR/Zygote(32): setreuid() failed. errno: 17
    05-10 14:24:48.968: ERROR/BatteryService(58): usbOnlinePath not found
    05-10 14:24:48.968: ERROR/BatteryService(58): batteryVoltagePath not found
    05-10 14:24:48.968: ERROR/BatteryService(58): batteryTemperaturePath not found
    05-10 14:24:48.998: ERROR/SurfaceFlinger(58): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
    05-10 14:24:55.769: ERROR/EventHub(58): could not get driver version for /dev/input/mouse0, Not a typewriter
    05-10 14:24:55.769: ERROR/EventHub(58): could not get driver version for /dev/input/mice, Not a typewriter
    05-10 14:24:56.009: ERROR/System(58): Failure starting core service
    05-10 14:24:56.009: ERROR/System(58): java.lang.SecurityException
    05-10 14:24:56.009: ERROR/System(58):     at android.os.BinderProxy.transact(Native Method)
    05-10 14:24:56.009: ERROR/System(58):     at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
    05-10 14:24:56.009: ERROR/System(58):     at android.os.ServiceManager.addService(ServiceManager.java:72)
    05-10 14:24:56.009: ERROR/System(58):     at com.android.server.ServerThread.run(SystemServer.java:184)
    05-10 14:24:57.149: ERROR/SoundPool(58): error loading /system/media/audio/ui/Effect_Tick.ogg
    05-10 14:24:57.149: ERROR/SoundPool(58): error loading /system/media/audio/ui/KeypressStandard.ogg
    05-10 14:24:57.169: ERROR/SoundPool(58): error loading /system/media/audio/ui/KeypressSpacebar.ogg
    05-10 14:24:57.169: ERROR/SoundPool(58): error loading /system/media/audio/ui/KeypressDelete.ogg
    05-10 14:24:57.169: ERROR/SoundPool(58): error loading /system/media/audio/ui/KeypressReturn.ogg
    05-10 14:24:59.689: ERROR/ThrottleService(58): Could not open GPS configuration file /etc/gps.conf
    05-10 14:25:01.529: ERROR/logwrapper(147): executing /system/bin/tc failed: No such file or directory
    05-10 14:25:01.569: ERROR/logwrapper(148): executing /system/bin/tc failed: No such file or directory
    05-10 14:25:01.639: ERROR/logwrapper(149): executing /system/bin/tc failed: No such file or directory
    05-10 14:25:14.804: ERROR/HierarchicalStateMachine(58): TetherMaster - unhandledMessage: msg.what=3
    05-10 14:25:38.444: ERROR/Database(277): Failure 1 (near "TABLEUsers": syntax error) on 0x1e6850 when preparing 'CREATE TABLEUsers(_idINTEGER primary key autoincrement,user_nametext not null,telephonetext not null,addresstext not null,mail_addresstext not null,);'.
    05-10 14:25:38.524: ERROR/AndroidRuntime(277): FATAL EXCEPTION: main
    05-10 14:25:38.524: ERROR/AndroidRuntime(277): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test/com.test.SQLiteTest3}: android.database.sqlite.SQLiteException: near "TABLEUsers": syntax error: CREATE TABLEUsers(_idINTEGER primary key autoincrement,user_nametext not null,telephonetext not null,addresstext not null,mail_addresstext not null,);
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at android.os.Handler.dispatchMessage(Handler.java:99)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at android.os.Looper.loop(Looper.java:123)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at android.app.ActivityThread.main(ActivityThread.java:4627)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at java.lang.reflect.Method.invokeNative(Native Method)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at java.lang.reflect.Method.invoke(Method.java:521)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at dalvik.system.NativeStart.main(Native Method)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277): Caused by: android.database.sqlite.SQLiteException: near "TABLEUsers": syntax error: CREATE TABLEUsers(_idINTEGER primary key autoincrement,user_nametext not null,telephonetext not null,addresstext not null,mail_addresstext not null,);
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at android.database.sqlite.SQLiteDatabase.native_execSQL(Native Method)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1727)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at com.test.SQLiteTest3$DBConnection.onCreate(SQLiteTest3.java:182)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:106)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at com.test.SQLiteTest3.onCreate(SQLiteTest3.java:52)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    05-10 14:25:38.524: ERROR/AndroidRuntime(277):     ... 11 more第一次发帖   还不怎么会   呵呵...
      

  2.   

    String sql = "CREATE TABLE " + UserSchema.TABLE_NAME + "("
    + UserSchema.ID + " INTEGER primary key autoincrement, "
    + UserSchema.USER_NAME + " text not null,"
    + UserSchema.TELEPHONE + " text not null,"
    + UserSchema.ADDRESS + " text not null,"
    + UserSchema.MAIL_ADDRESS + " text not null," + ");";
    db.execSQL(sql);
      

  3.   

    05-10 14:25:38.524: ERROR/AndroidRuntime(277): Caused by: android.database.sqlite.SQLiteException: near "TABLEUsers": syntax error: CREATE TABLEUsers(_idINTEGER primary key autoincrement,user_nametext not null,telephonetext not null,addresstext not null,mail_addresstext not null,);
    这就是楼主程序出错的原因:CTEATE TABLEusers出错,即sql语句出错啦
    String sql = "CREATE TABLE " + UserSchema.TABLE_NAME + "("
    + UserSchema.ID + " INTEGER primary key autoincrement, "
    + UserSchema.USER_NAME + " text not null,"
    + UserSchema.TELEPHONE + " text not null,"
    + UserSchema.ADDRESS + " text not null,"
    + UserSchema.MAIL_ADDRESS + " text not null," + ");";db.execSQL(sql);
    楼主试试吧!
      

  4.   

    String sql = "CREATE TABLE" + UserSchema.TABLE_NAME + "("这句话 TABLE后要个空格啊"CREATE TABLE "
      

  5.   

    package com.test;import android.app.Activity;
    import android.content.ContentValues;
    import android.content.Context;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.AdapterView;
    import android.widget.ArrayAdapter;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.Spinner;
    import android.widget.AdapterView.OnItemSelectedListener;public class SQLiteTest3 extends Activity {
    /** Called when the activity is first created. */
    OnClickListener listener_add = null;
    OnClickListener listener_update = null;
    OnClickListener listener_delete = null;
    OnClickListener listener_clear = null;
    Button button_add = null;
    Button button_update = null;
    Button button_delete = null;
    Button button_clear = null;
    DBConnection helper;
    public int id_this; public interface UserSchema {
    String TABLE_NAME = "Users";
    String ID = "_id";
    String USER_NAME = "user_name";
    String ADDRESS = "address";
    String TELEPHONE = "telephone";
    String MAIL_ADDRESS = "mail_address";
    } @Override
    public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final EditText editText01 = (EditText) findViewById(R.id.EditText01);
    final EditText editText02 = (EditText) findViewById(R.id.EditText02);
    final EditText editText03 = (EditText) findViewById(R.id.EditText03);
    final EditText editText04 = (EditText) findViewById(R.id.EditText04);
    helper = new DBConnection(this);

    final SQLiteDatabase db = helper.getWritableDatabase();
    final String [] FROM = { UserSchema.ID, UserSchema.USER_NAME,
    UserSchema.TELEPHONE, UserSchema.ADDRESS,
    UserSchema.MAIL_ADDRESS };
    System.out.println(1); Cursor c = db.query(UserSchema.TABLE_NAME,
    new String [] { UserSchema.USER_NAME }, null, null, null, null,
    null);
    c.moveToFirst();
    CharSequence [] list = new CharSequence[c.getCount()];
    for (int i = 0; i < list.length; i++) {
    list[i] = c.getString(0);
    c.moveToNext();
    }
    c.close();
    System.out.println(2);

    Spinner spinner = (Spinner) findViewById(R.id.Spinner01);
    spinner.setAdapter(new ArrayAdapter<CharSequence>(this,
    android.R.layout.simple_spinner_item, list));
    spinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view,
    int position, long id) {
    String user_name = ((Spinner) parent).getSelectedItem()
    .toString();
    Cursor c = db.query("Users", FROM, "user_name ='" + user_name
    + "'", null, null, null, null);
    c.moveToFirst();
    System.out.println(3);

    id_this = Integer.parseInt(c.getString(0));
    String user_name_this = c.getString(1);
    String telephone_this = c.getString(2);
    String address_this = c.getString(3);
    String mail_address_this = c.getString(4);
    c.close();
    editText01.setText(user_name_this);
    editText02.setText(telephone_this);
    editText03.setText(address_this);
    editText04.setText(mail_address_this); } public void onNothingSelected(AdapterView<?> parent) { }
    });
    listener_add = new OnClickListener() { public void onClick(View v) {
    ContentValues values = new ContentValues();
    values.put(UserSchema.USER_NAME, editText01.getText()
    .toString());
    values.put(UserSchema.TELEPHONE, editText02.getText()
    .toString());
    values.put(UserSchema.MAIL_ADDRESS, editText03.getText()
    .toString());
    values.put(UserSchema.ADDRESS, editText04.getText().toString());
    SQLiteDatabase db = helper.getWritableDatabase();
    System.out.println(4);
    db.insert(UserSchema.TABLE_NAME, null, values);
    System.out.println(5);
    db.close();
    onCreate(savedInstanceState);
    }
    };
    listener_update = new OnClickListener() { public void onClick(View v) {
    ContentValues values = new ContentValues();
    values.put(UserSchema.USER_NAME, editText01.getText()
    .toString());
    values.put(UserSchema.TELEPHONE, editText02.getText()
    .toString());
    values.put(UserSchema.MAIL_ADDRESS, editText03.getText()
    .toString());
    values.put(UserSchema.ADDRESS, editText04.getText().toString());
    String where = UserSchema.ID + " = " + id_this;
    SQLiteDatabase db = helper.getWritableDatabase();
    db.update(UserSchema.TABLE_NAME, values, where, null);
    db.close();
    onCreate(savedInstanceState); }
    };
    listener_delete = new OnClickListener() { public void onClick(View v) {
    String where = UserSchema.ID + "=" + id_this;
    SQLiteDatabase db = helper.getWritableDatabase();
    db.delete(UserSchema.TABLE_NAME, where, null);
    db.close();
    onCreate(savedInstanceState);
    }
    };
    listener_clear = new OnClickListener() { public void onClick(View v) {
    // TODO Auto-generated method stub
    editText01.setText("");
    editText02.setText("");
    editText04.setText("");
    editText03.setText(""); }
    };
    button_add = (Button) findViewById(R.id.Button01);
    button_add.setOnClickListener(listener_add);
    button_update = (Button) findViewById(R.id.Button02);
    button_update.setOnClickListener(listener_update);
    button_delete = (Button) findViewById(R.id.Button03);
    button_delete.setOnClickListener(listener_delete);
    button_clear = (Button) findViewById(R.id.Button04);
    button_clear.setOnClickListener(listener_clear); } public static class DBConnection extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "PhoneBookDB";
    private static final int DATABASE_VERTION = 1; private DBConnection(Context ctx) {
    super(ctx, DATABASE_NAME, null, DATABASE_VERTION); }
    public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub
    String sql = " CREATE TABLE " + UserSchema.TABLE_NAME + "("
    + UserSchema.ID + " INTEGER primary key autoincrement,"
    + UserSchema.USER_NAME + " text not null , "
    + UserSchema.TELEPHONE + " text not null , "
    + UserSchema.ADDRESS + " text not null , "
    + UserSchema.MAIL_ADDRESS + " text not null " + " ) ";
    System.out.println(sql);
    db.execSQL(sql); } @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // TODO Auto-generated method stub } }
    }终于搞定了    就错在两个空格上了  
    看来还是粗心不得啊  
    不过还得谢谢帮助我的人
    学习了!