I am inserting data in table with current system time like
System.currentTimeMillis()
. So, while getting data I need to take last 3 hours data only.
You can get TimeStamp of Time 3 Hours back using following
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR, -3);
Date threeHourBack = cal.getTime();
Then you can pass threeHourBack.getTime()
to the query.
Or You can do this in SQLite
SELECT * FROM Table1 where datetime(timestamp) >=datetime('now', '-3 Hour')