Java Code Examples for com.lidroid.xutils.DbUtils#configAllowTransaction()

The following examples show how to use com.lidroid.xutils.DbUtils#configAllowTransaction() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyEventLogicImpl.java    From ALLGO with Apache License 2.0 6 votes vote down vote up
@Override
public void saveEvent(ArrayList<EventVo> eventsData) {
	
	SharedPreferences sharedPref = context.getSharedPreferences("userdata",Context.MODE_PRIVATE);
	int uid = sharedPref.getInt("uid", -1) ;
   	try{
	    DbUtils db = DbUtils.create(context,uid + ".db");
	    db.configAllowTransaction(true);
        db.configDebug(true);
        db.deleteAll(MyEventVo.class);
        Log.i("DB", "deleteAll =saveBindingId=>" + eventsData.size()) ;
        for(int i=0 ; i<20 && i<eventsData.size() ; i++){
        	db.save(ChangEventVo.event2MyEvent(eventsData.get(i)));
        }
		}catch(DbException e){
	    	Log.e("DB", "error :" + e.getMessage() + "\n");
	    }

}
 
Example 2
Source File: PastEventLogicImpl.java    From ALLGO with Apache License 2.0 6 votes vote down vote up
@Override
public void saveEvent(ArrayList<EventVo> eventsData) {
	
	SharedPreferences sharedPref = context.getSharedPreferences("userdata",Context.MODE_PRIVATE);
	int uid = sharedPref.getInt("uid", -1) ;
   	try{
	    DbUtils db = DbUtils.create(context,uid + ".db");
	    db.configAllowTransaction(true);
        db.configDebug(true);
        db.deleteAll(PastEventVo.class);
        Log.i("DB", "deleteAll =saveBindingId=>" + eventsData.size()) ;
        for(int i=0 ; i<20 && i<eventsData.size() ; i++){
        	db.save(ChangEventVo.event2PastEvent(eventsData.get(i)));
        }
		}catch(DbException e){
	    	Log.e("DB", "error :" + e.getMessage() + "\n");
	    }

}
 
Example 3
Source File: FriendsEventLogicImpl.java    From ALLGO with Apache License 2.0 6 votes vote down vote up
/**
 * 保存列表数据到数据库
 * @param eventsData
 */
@Override
public void saveEvent(ArrayList<EventVo> eventsData) {
	SharedPreferences sharedPref = context.getSharedPreferences("userdata",Context.MODE_PRIVATE);
	int uid = sharedPref.getInt("uid", -1) ;
   	try{
	    DbUtils db = DbUtils.create(context,uid + ".db");
	    db.configAllowTransaction(true);
        db.configDebug(true);
        db.deleteAll(FriendEventVo.class);
        Log.i("DB", "deleteAll =saveFriendEvent=>" + eventsData.size()) ;
        for(int i=0 ; i<20 && i<eventsData.size() ; i++){
        	db.save(ChangEventVo.event2FriendEvent(eventsData.get(i)));
        }
		}catch(DbException e){
	    	Log.e("DB", "error :" + e.getMessage() + "\n");
	    }
}
 
Example 4
Source File: CommonEventLogicImpl.java    From ALLGO with Apache License 2.0 6 votes vote down vote up
/**
 * 保存列表数据到数据库
 * @param context
 * @param eventsData
 */
@Override
public void saveEvent(ArrayList<EventVo> eventsData) {
	
	SharedPreferences sharedPref = context.getSharedPreferences("userdata",Context.MODE_PRIVATE);
	int uid = sharedPref.getInt("uid", -1) ;
   	try{
	    DbUtils db = DbUtils.create(context,uid + ".db");
	    db.configAllowTransaction(true);
        db.configDebug(true);
        db.deleteAll(CommonEventVo.class);
        Log.i("DB", "deleteAll =saveCommonEvent=>" + eventsData.size()) ;
        for(int i=0 ; i<20 && i<eventsData.size() ; i++){
        	db.save(ChangEventVo.event2CommonEvent(eventsData.get(i)));
        }
		}catch(DbException e){
	    	Log.e("DB", "error :" + e.getMessage() + "\n");
	    }
}
 
Example 5
Source File: UnreadLogicImpl.java    From ALLGO with Apache License 2.0 6 votes vote down vote up
/**
 * 结束保存
 */
@Override
public void saveUnread(ArrayList<UnreadVo> unreadDate) {

	SharedPreferences sharedPref = context.getSharedPreferences("userdata",Context.MODE_PRIVATE);
	int uid = sharedPref.getInt("uid", -1) ;
   	try{
	    DbUtils db = DbUtils.create(context,uid + ".db");
	    db.configAllowTransaction(true);
        db.configDebug(true);
        Log.i("DB", "deleteNo =saveUnread=>" + unreadDate.size()) ;
        for(int i=0 ; i<unreadDate.size() ; i++){
        	db.saveOrUpdate(unreadDate.get(i));
        }
		}catch(DbException e){
	    	Log.e("DB", "error :" + e.getMessage() + "\n");
	    }
}
 
Example 6
Source File: UnreadLogicImpl.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
@Override
public void setRead(UnreadVo unread) {
	SharedPreferences sharedPref = context.getSharedPreferences("userdata",Context.MODE_PRIVATE);
	int uid = sharedPref.getInt("uid", -1) ;
   	try{
   		unread.setIsread(true);
	    DbUtils db = DbUtils.create(context,uid + ".db");
	    db.configAllowTransaction(true);
        db.configDebug(true);
        db.saveOrUpdate(unread);
		}catch(DbException e){
	    	Log.e("DB", "error :" + e.getMessage() + "\n");
	    }
	
}
 
Example 7
Source File: test.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
public void test1(){
	ArrayList<FriendEventVo> eventsDate =new ArrayList<FriendEventVo>() ;
	eventsDate.add(new FriendEventVo(11002617,"去栖霞山爬山",123456,"千军万马1",
   			"Mon Feb 15 08:00:00 GMT+08:00 2014",null,"去栖霞山爬山","栖霞山",
   			"江苏省 南京市 栖霞区","Mon Feb 13 08:00:00 GMT+08:00 2013","旅游",0,
   			0,0));
	eventsDate.add(new FriendEventVo(11002618,"去栖霞山爬山",123456,"千军万马2",
   			"Mon Feb 15 08:00:00 GMT+08:00 2014",null,"去栖霞山爬山","栖霞山",
   			"江苏省 南京市 栖霞区","Mon Feb 13 08:00:00 GMT+08:00 2013","旅游",0,
   			0,0));
	eventsDate.add(new FriendEventVo(11002619,"去栖霞山爬山",123456,"千军万马3",
   			"Mon Feb 15 08:00:00 GMT+08:00 2014",null,"去栖霞山爬山","栖霞山",
   			"江苏省 南京市 栖霞区","Mon Feb 13 08:00:00 GMT+08:00 2013","旅游",0,
   			0,0));
	
	try{
	    DbUtils db = DbUtils.create(this.getContext(),"123456.db");
	    db.configAllowTransaction(true);
        db.configDebug(true);
        db.saveBindingIdAll(eventsDate);
        
        //List<EventVo> events = db.findAll(Selector.from(FriendEventVo.class));
        //Log.i("DB", "Parents size:" + events.get(0) + "\n") ;

        
	}catch(DbException e){
    	Log.e("DB", "error :" + e.getMessage() + "\n");
    }
}