Android数据库映射,使用dbcontract还是实体类?
2个回答
2016-02-02 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
Android数据库映射,使用dbcontract比较推荐:
举例如下:
package com.melissanoelle.groovebasin.data;
import android.content.ContentUris;
import android.net.Uri;
import android.provider.BaseColumns;
/**
* Created by mel on 2/21/15.
*/
public class DbContract {
public static final String CONTENT_AUTHORITY = "com.melissanoelle.groovebasin";
public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY);
public static final String PATH_GROOVEBASIN = "groovebasin";
public static final class GroovebasinEntry implements BaseColumns {
public static final String TABLE_NAME = "groovebasins";
public static final String COLUMN_NAME = "name";
public static final String COLUMN_URL = "url";
public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_GROOVEBASIN).build();
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/" + CONTENT_AUTHORITY + "/" + PATH_GROOVEBASIN;
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/" + CONTENT_AUTHORITY + "/" + PATH_GROOVEBASIN;
public static Uri buildGroovebasinUri(long id) {
return ContentUris.withAppendedId(CONTENT_URI, id);
}
public static Uri returnContentUri() { return CONTENT_URI; }
}
}
举例如下:
package com.melissanoelle.groovebasin.data;
import android.content.ContentUris;
import android.net.Uri;
import android.provider.BaseColumns;
/**
* Created by mel on 2/21/15.
*/
public class DbContract {
public static final String CONTENT_AUTHORITY = "com.melissanoelle.groovebasin";
public static final Uri BASE_CONTENT_URI = Uri.parse("content://" + CONTENT_AUTHORITY);
public static final String PATH_GROOVEBASIN = "groovebasin";
public static final class GroovebasinEntry implements BaseColumns {
public static final String TABLE_NAME = "groovebasins";
public static final String COLUMN_NAME = "name";
public static final String COLUMN_URL = "url";
public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon().appendPath(PATH_GROOVEBASIN).build();
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/" + CONTENT_AUTHORITY + "/" + PATH_GROOVEBASIN;
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/" + CONTENT_AUTHORITY + "/" + PATH_GROOVEBASIN;
public static Uri buildGroovebasinUri(long id) {
return ContentUris.withAppendedId(CONTENT_URI, id);
}
public static Uri returnContentUri() { return CONTENT_URI; }
}
}
大雅新科技有限公司
2024-11-19 广告
2024-11-19 广告
这方面更多更全面的信息其实可以找下大雅新。深圳市大雅新科技有限公司从事KVM延长器,DVI延长器,USB延长器,键盘鼠标延长器,双绞线视频传输器,VGA视频双绞线传输器,VGA延长器,VGA视频延长器,DVI KVM 切换器等,优质供应商,...
点击进入详情页
本回答由大雅新科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询