1. Download our Official Android App: Forums for Android!

Apps foreign key for sql lite

Discussion in 'Android Development' started by cowboy, Mar 22, 2010.

  1. cowboy

    cowboy Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Mar 22, 2010

    Mar 22, 2010
    4
    0
    5
    Hello every one! I have some problem with my SQL request. I am trying to create tables like this :
    Code (Text):
    1.  myDB.execSQL("CREATE TABLE IF NOT EXISTS "
    2.               + categories
    3.               + " (category_id PRIMARY KEY,parent_id INT,FOREIGN KEY(parent_id) REFERENCES categories(category_id),name text,amount float);");
    4.       myDB.execSQL("CREATE TABLE IF NOT EXISTS "
    5.               + accounts
    6.               + " (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?
     

    Advertisement

  2. kiranuday43

    kiranuday43 Newbie
    Rank:
    None
    Points:
    15
    Posts:
    20
    Joined:
    Mar 3, 2010

    Mar 3, 2010
    20
    0
    15
    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,,
     

Share This Page

Loading...