Numberformatexception:invalid int Type mismatch exception--Use SQL database query statement SELECT * FROM Blacknumber ORDER by _id desc limit?, 20; appears

Source: Internet
Author: User

Exception: Type mismatch


05-06 08:12:38.151:e/androidruntime (14904): Java.lang. numberformatexception:invalid int: "18600000099"

05-06 08:12:38.151:e/androidruntime (14904): at com.itheima.mobilesafe74.activity.blacknumberactivity$ Myadapter.getview (blacknumberactivity.java:122)

1  PublicList<blacknumberinfo> Find (intindex)2     {3 //to get the database object first4Sqlitedatabase db =blacknumberopenhelper.getwritabledatabase ();5 //The first parameter in Db.rawquery () is the SQL statement, and the second parameter is? The corresponding value6        cursor cursor = db.rawquery ("SELECT * from Blacknumber ORDER by _id desc limit?", " new string[]{index+" " });7 //in order to get all the fields found, create a collection package8List<blacknumberinfo> blacknumberlist =NewArraylist<blacknumberinfo>();9          while(Cursor.movetonext ())Ten         { One //encapsulates two fields of a query into a Java bean ABlacknumberinfo Blacknumberinfo =Newblacknumberinfo (); -             blacknumberinfo.phone = cursor.getstring (0); Blacknumberinfo.mode = cursor.getstring (1);   the //Each loop encapsulates the JavaBean into the collection. - Blacknumberlist.add (blacknumberinfo); -         } - cursor.close (); + db.close (); -         returnblacknumberlist; +}

Code line Sixth

SELECT * FROM Blacknumber
Represents all fields of the query
and

There are _id,phone,mode three fields in the database
So when calling code 13, 14 lines
Blacknumberinfo.phone = cursor.getstring (0); blacknumberinfo.mode = cursor.getstring (1);
0 corresponds to the _id, not the phone.
1 corresponds to the phone, not the mode.
So there's a problem.
Modify the SQL query statement to solve this problem:
For the six lines, replace
cursor cursor = db.rawquery ("Select Phone,mode from Blacknumber ORDER by _id desc limit?", New string[]{index+ ""} );
Can




Numberformatexception:invalid int Type mismatch exception--Use SQL database query statement SELECT * FROM Blacknumber ORDER by _id desc limit?, 20; appears

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.