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

Apps How to delete from SQLite

Discussion in 'Android Development' started by hno2005, Nov 29, 2012.

  1. hno2005

    hno2005 Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    13
    Joined:
    Jul 2, 2012

    Jul 2, 2012
    13
    0
    15
    Hi every one
    i want to run a delete query with limitation .
    I've tried to many queries but they didn't work .
    For know , I just want to remove all the rows and I write this code "

    DELETE FROM tbl1 where _id IN(select _id from tbl1 WHERE cat=21)

    The emulator runs perfectly without any error .
    right now , I have 32 rows with cat = 21 .

    could you help me to solve this problem ?

    Thanks
     

    Advertisement

  2. mills2533

    mills2533 Well-Known Member
    Rank:
    None
    Points:
    38
    Posts:
    150
    Joined:
    Dec 21, 2010

    Dec 21, 2010
    150
    22
    38
    Colorado (USA)
    Isn't that the same as:

    DELETE FROM tbl1 WHERE cat=21
     
  3. jonbonazza

    jonbonazza Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    Yes, this query is the same and also much cleaner than the OP's query.

    As for why it is not working on the device, but does on the emulator, it's hard to tell with the given information. Do you receive an exception? An SQL Error code? Both?
     
  4. junchronick

    junchronick Lurker
    Rank:
    None
    Points:
    26
    Posts:
    3
    Joined:
    Apr 18, 2013

    Apr 18, 2013
    3
    1
    26
    can I get the full codes?
     

Share This Page

Loading...