The first data in SQLite database is not found!

Source: Internet
Author: User
Tags sqlite database

/**
* * title:selectallphone *description: Query All Phone objects * @return * @see
* Com.sms.ntlm.dao.phonedao#selectallphone ()
*/
@SuppressLint ("SimpleDateFormat")
@SuppressWarnings ("deprecation")
@Override
Public list<phone> Selectallphone () {
Cursor cursor=null;
list<phone> list=new arraylist<phone> ();
String sql= "select * from" +phonesqlconstant.table_name+ ";";
db=mopenhelper.getwritabledatabase ();
if (mopenhelper!=null && db.isopen ()) {
//Cursor=db.query (phonesqlconstant.table_name, NULL, NULL, NULL , NULL, NULL, NULL);
cursor=db.rawquery (SQL, NULL);
}
if (cursor! = NULL) {//cause this is where the error occurred: I added an if (cursor! = NULL && Cursor.movetofirst ()) to this place {
While (Cursor.movetonext ()) {
phone phone=new phone ();

Phone.setphoneid (Cursor.getint (Cursor.getcolumnindex (phonesqlconstant.phone_id)));
Phone.setphonenum (cursor.getstring (Cursor.getcolumnindex (Phonesqlconstant.phone_num)));
phone.setphonedate (cursor.getstring (Cursor.getcolumnindex (phonesqlconstant.phone_date)));

List.add (phone);
}
}
This.closecursordb (cursor);
return list;

}


The result of the console output is : 05-15 03:12:44.017:i/system.out (12634): Testselectallphone.size (...) ..... 0

The result of my query in the database is:

D:\zzz>sqlite3 phonemassage.db
SQLite version 3.7.11 2012-03-20 11:35:50
Enter '. Help ' for instructions
Enter SQL statements terminated with a ";"
Sqlite>. Table
Myphone Phone Android_metadata
Sqlite> SELECT * from Myphone
...>;
1|1234|2015-05-15
Sqlite> ^c


The first data in the

SQLite database cannot be found!

Related Article

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.