New file |
| | |
| | | package cn.com.basic.face.service.sqlite;
|
| | |
|
| | | import android.database.Cursor;
|
| | |
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.Date;
|
| | |
|
| | | import cn.com.basic.face.base.MainActivity;
|
| | | import cn.com.basic.face.discern.entity.VisitTableSynchronRecord;
|
| | |
|
| | | /**
|
| | | * 同步记录表dao
|
| | | * Created by SJW on 2017/7/25 0025.
|
| | | */
|
| | |
|
| | | public class SynchronRecordDao {
|
| | |
|
| | | public static SynchronRecordDao instance=new SynchronRecordDao();
|
| | | public static SynchronRecordDao getInstance(){
|
| | | return instance;
|
| | | }
|
| | |
|
| | | /***
|
| | | * 加载同步记录表
|
| | | * @param tableName 表名
|
| | | * @return
|
| | | */
|
| | | public VisitTableSynchronRecord getSynRecord(String tableName){
|
| | | String sql="select * from visit_table_synchron_record where table_name='" + tableName + "'";
|
| | | VisitTableSynchronRecord record=null;
|
| | | Cursor c = MainActivity.getInstance().db.rawQuery(sql,new String[]{});
|
| | | if(c.moveToFirst()){
|
| | | record=new VisitTableSynchronRecord();
|
| | | record.setId(c.getString(c.getColumnIndex("id")));
|
| | | record.setSynchronTime(c.getString(c.getColumnIndex("synchron_time")));
|
| | | record.setTableName(tableName);
|
| | | return record;
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 更新记录
|
| | | * @param tableName 表名
|
| | | * @param synDate 最近一次同步时间
|
| | | */
|
| | | public void updateSynRecord(String tableName, Date synDate){
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | | String sql="update visit_table_synchron_record set synchron_time="+"'"+sdf.format(synDate)+"'"+" where table_name='" + tableName + "'";
|
| | | MainActivity.getInstance().db.execSQL(sql);
|
| | | }
|
| | |
|
| | | }
|