Back to project page android_twitter_client.
The source code is released under:
GNU General Public License
If you think the Android project android_twitter_client listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.github.snambi.twitterclient.db; /*from w w w.j ava 2s.c o m*/ import java.util.List; import com.activeandroid.ActiveAndroid; import com.activeandroid.query.From; import com.activeandroid.query.Select; import com.github.snambi.twitterclient.models.Tweet; public class TweetDbHelper { public static boolean existsInDb( List<Tweet> tweets ){ boolean result = true; // if all the tweets are already present in the table, then return "true" Select select = new Select(); for( Tweet tweet: tweets ){ Tweet t = select.from(Tweet.class).where("uid == ? ", tweet.getUid() ).executeSingle(); if( t != null || t.getUid() == 0 ){ // its fake result=false; break; } } return result; } public static void saveWhenNotPresent( List<Tweet> tweets ){ try { ActiveAndroid.beginTransaction(); Select select = new Select(); From from = select.from(Tweet.class); for( Tweet tweet : tweets ){ Tweet t = from.where("uid == ? ", tweet.getUid() ).executeSingle(); if( t==null ){ tweet.save(); } } ActiveAndroid.setTransactionSuccessful(); }finally{ ActiveAndroid.endTransaction(); } } }