Android编程入门-第31天

CrimeCursorWrapper.java

import java.util.Date;
import java.util.UUID;

public class CrimeCursorWrapper extends CursorWrapper {

    public CrimeCursorWrapper(Cursor cursor) {
        super(cursor);
    }

    public Crime getCrime() {
        String uuidString = getString(getColumnIndex(CrimeTable.Cols.UUID));
        String title = getString(getColumnIndex(CrimeTable.Cols.TITLE));
        long date = getLong(getColumnIndex(CrimeTable.Cols.DATE));
        int isSolved = getInt(getColumnIndex(CrimeTable.Cols.SOLVED));

        Crime crime = new Crime(UUID.fromString(uuidString));
        crime.setTitle(title);
        crime.setDate(new Date(date));
        crime.setSolved(isSolved != 0);

        return crime;
    }
}

CrimeDbSchema,java

public class CrimeDbSchema {
    public static final class CrimeTable {
        public static final String NAME = "crimes";

        public static final class Cols {
            public static final String UUID = "uuid";
            public static final String TITLE = "title";
            public static final String DATE = "date";
            public static final String SOLVED = "solved";
        }
    }
}
阅读更多
个人分类: Android开发
上一篇Android编程入门-第30天
下一篇Android编程入门-第32天
想对作者说点什么? 我来说一句

31天学会CRM项目开发完整扫描版PDF

2018年02月27日 87.55MB 下载

31天学会CRM项目开发

2017年11月12日 86.14MB 下载

没有更多推荐了,返回首页

关闭
关闭
关闭