Android: SQLite select data using SQL statement returning cursor

person Jason Huangfolder_openAndroid, Code, Java, SQLitelocal_offer, , , , , access_time September 21, 2010

Use the .rawQuery function to use a SQL statement to retrieve data into cursor.


	    public Cursor fetchAllDineoutHistoryFormatDate(){
 
	    	String sSelect = "SELECT " + K_ROWID + ", " + K_TITLE + ", " + K_DATE + ", " +
	    					"strftime('%" +
	    					"H:%M:%S'," + K_TIME + ", 'localtime') as "
	    	                  + K_TIME + ", " + K_MEAL + ", " + K_TOTAL + " FROM " + DATABASE_TABLE + " ORDER BY "
	    	                  + K_DATE + " desc, " + K_TIME + " desc";
	    	return mDb.rawQuery(sSelect, null);
	    }
            

Comment

  1. Great post. I like your blog. Thanx.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>