Project Clean会导致app失败

时间:2013-11-09 20:45:38

标签: android

我刚刚在一个正常工作的应用程序上从ADT做了一个干净,现在它崩溃了。这就是我所知道的......

这是主要应用......

public class MainActivity extends Activity {
private GolferDBManager mydManager;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Go get the Known Golfers
    mydManager = new GolferDBManager(this);
    mydManager.openReadable();
    mydManager.retrieveGolfers();
    mydManager.close();

}

这是GolferDBManager类:

public class GolferDBManager {
public static final String DB_NAME = "golfgames";
public static final String DB_TABLE = "golfers";
public static final int DB_VERSION = 1;
private static final String CREATE_TABLE = "CREATE TABLE " + DB_TABLE + " (index INTEGER PRIMARY KEY, golfer_name TEXT, golfer_init TEXT, usga_index DOUBLE);";
private SQLHelper helper;
private SQLiteDatabase db;
private Context context;


public GolferDBManager(Context c){
    this.context = c;
    helper=new SQLHelper(c);
    this.db = helper.getWritableDatabase();
}
public class SQLHelper extends SQLiteOpenHelper {
    public SQLHelper(Context c){
        super(c, DB_NAME, null, DB_VERSION);
    }

它在

上崩溃了
    this.db = helper.getWritableDatabase();

        mydManager = new GolferDBManager(this);

主要应用程序中有2行。

清理搞砸数据库了吗?

这是调试堆栈

Thread [<1> main] (Suspended (exception RuntimeException))  
<VM does not provide monitor information>   
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2211    
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 2261 
ActivityThread.access$600(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 141    
ActivityThread$H.handleMessage(Message) line: 1256  
ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
Looper.loop() line: 137 
ActivityThread.main(String[]) line: 5103    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
Method.invoke(Object, Object...) line: 525  
ZygoteInit$MethodAndArgsCaller.run() line: 737  
ZygoteInit.main(String[]) line: 553 
NativeStart.main(String[]) line: not available [native method]  

Logcat说:

11-09 16:19:54.386: E/SQLiteLog(1184): (1) near "index": syntax error

感谢。

1 个答案:

答案 0 :(得分:0)

中定义数据库的字段时,我使用 index 作为字段名称
CREATE_TABLE= ...

。不知道为什么它一直在工作 - 它永远不应该。但将其更改为另一个名称可以解决问题。

感谢您的光临。

DDK