I parsed the json data and put these values in database(Sqlite database). Next time when i open the activity it again parsed the data and put these values in database. so i want to check first whether data is in sqlite?, if so then i need to skip parsing. And just get these values from database. how can i do this?
3
-
2Simple SELECT Query which returns Cursor with data is enough for this.user370305– user3703052012-08-21 05:21:07 +00:00Commented Aug 21, 2012 at 5:21
-
Refer this link stackoverflow.com/questions/11361722/…rajeshwaran– rajeshwaran2012-08-21 05:21:16 +00:00Commented Aug 21, 2012 at 5:21
-
I'm not sure what you mean. Try to check if you can read data from SQLite: SELECT * FROM YourTableBruno Bieri– Bruno Bieri2012-08-21 05:22:02 +00:00Commented Aug 21, 2012 at 5:22
Add a comment
|
1 Answer
Try this.
public int isDataAvailable()
{
int total = 0;
try
{
Cursor c = null;
c = db.rawQuery("select id from mycoupon", null);
if(c.getCount() != 0)
total = c.getCount();
c.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return total;
}
If there are no records in table then it returns 0 otherwise returns no of records.
1 Comment
Chirag
@Brinda-user1594986 Always Welcome