• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps foreign key for sql lite

cowboy

Lurker
Hello every one! I have some problem with my SQL request. I am trying to create tables like this :
Code:
 myDB.execSQL("CREATE TABLE IF NOT EXISTS "
    		  + categories
    		  + " (category_id PRIMARY KEY,parent_id INT,FOREIGN KEY(parent_id) REFERENCES categories(category_id),name text,amount float);"); 
      myDB.execSQL("CREATE TABLE IF NOT EXISTS "
    		  + accounts
    		  + " (account_id PRIMARY KEY, name text);");

It is compiled ok. But then i tried to run it on emulator the app has dropped with error :
APPLICATION HAS STOPPED UNEXPECTADLY.

And i ve finded error occur in the FOREIGN KEY. WHAT problem?
 
FOREIGN_KEY is used between the two tables,,,I found that you are referencing the attribute in the same table,,,and two attributes name should be same,,
 
Back
Top Bottom