实现多个ContentProvider对多张表进行操作
http://blog.csdn.net/maylian7700/article/details/7365373
SQLite数据库直接操作类:
DatabaseHelper.java
- package com.jacp.database;
- import android.content.Context;
- import android.database.sqlite.SQLiteDatabase;
- import android.database.sqlite.SQLiteOpenHelper;
- import com.jacp.demo.provider.Provider;
- public class DatabaseHelper extends SQLiteOpenHelper {
- private static final String DATABASE_NAME = "jacp_demo.db";
- private static final int DATABASE_VERSION = 1;
- public DatabaseHelper(Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- }
- @Override
- public void onCreate(SQLiteDatabase db) {
- // 创建programmer表
- db.execSQL("CREATE TABLE " + Provider.ProgrammerColumns.TABLE_NAME + " ("
- + Provider.ProgrammerColumns._ID + " INTEGER PRIMARY KEY,"
- + Provider.ProgrammerColumns.NAME + " TEXT,"
- + Provider.ProgrammerColumns.AGE + " INTEGER"
- + ");");
- // 创建leader表
- db.execSQL("CREATE TABLE " + Provider.LeaderColumns.TABLE_NAME + " ("
- + Provider.LeaderColumns._ID + " INTEGER PRIMARY KEY,"
- + Provider.LeaderColumns.NAME + " TEXT,"
- + Provider.LeaderColumns.TITLE + " TEXT,"
- + Provider.LeaderColumns.LEVEL + " INTEGER"
- + ");");
- }
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- db.execSQL("DROP TABLE IF EXISTS " + Provider.ProgrammerColumns.TABLE_NAME);
- db.execSQL("DROP TABLE IF EXISTS " + Provider.LeaderColumns.TABLE_NAME);
- onCreate(db);
- }
- }
保存跟数据库及表有关的常量:
Provider.java
- package com.jacp.demo.provider;
- import android.net.Uri;
- import android.provider.BaseColumns;
- /**
- * 保存数据库中的常量
- * @author jacp
- *
- */
- public class Provider {
- public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.jacp.demo";
- public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.jacp.demo";
- /**
- * 保存programmer表中用到的常量
- * @author jacp
- *
- */
- public static final class ProgrammerColumns implements BaseColumns {
- // 注意两张表的authority要不一样
- public static final String AUTHORITY = "com.jacp.provider.demo.programmer";
- public static final Uri CONTENT_URI = Uri.parse("content://"+ AUTHORITY +"/programmers");
- public static final String TABLE_NAME = "programmer";
- public static final String DEFAULT_SORT_ORDER = "age desc";
- public static final String NAME = "name";
- public static final String AGE = "age";
- }
- /**
- * 保存leader表中用到的常量
- * @author mayliang
- *
- */
- public static final class LeaderColumns implements BaseColumns {
- public static final String AUTHORITY = "com.jacp.provider.demo.leader";
- public static final Uri CONTENT_URI = Uri.parse("content://"+ AUTHORITY +"/leaders");
- public static final String TABLE_NAME = "leader";
- public static final String DEFAULT_SORT_ORDER = "level desc";
- public static final String NAME = "name";
- public static final String TITLE = "title";
- public static final String LEVEL = "level";
- }
- }
对leader表进行增删改查操作的ContentProvider类:
LeaderProvider.java
- package com.jacp.demo.provider;
- import java.util.HashMap;
- import android.content.ContentProvider;
- import android.content.ContentUris;
- import android.content.ContentValues;
- import android.content.UriMatcher;
- import android.database.Cursor;
- import android.database.SQLException;
- import android.database.sqlite.SQLiteDatabase;
- import android.database.sqlite.SQLiteQueryBuilder;
- import android.net.Uri;
- import android.text.TextUtils;
- import com.jacp.database.DatabaseHelper;
- /**
- * 对leader表进行操作的ContentProvider
- * @author jacp
- *
- */
- public class LeaderProvider extends ContentProvider {
- private static HashMap<String, String> sLeadersProjectionMap;
- private static final int LEADERS = 1;
- private static final int LEADER_ID = 2;
- private static final UriMatcher sUriMatcher;
- private DatabaseHelper mOpenHelper;
- @Override
- public boolean onCreate() {
- mOpenHelper = new DatabaseHelper(getContext());
- return true;
- }
- @Override
- public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
- String sortOrder) {
- SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
- qb.setTables(Provider.LeaderColumns.TABLE_NAME);
- switch (sUriMatcher.match(uri)) {
- case LEADERS:
- qb.setProjectionMap(sLeadersProjectionMap);
- break;
- case LEADER_ID:
- qb.setProjectionMap(sLeadersProjectionMap);
- qb.appendWhere(Provider.LeaderColumns._ID + "=" + uri.getPathSegments().get(1));
- break;
- default:
- throw new IllegalArgumentException("Unknown URI " + uri);
- }
- // If no sort order is specified use the default
- String orderBy;
- if (TextUtils.isEmpty(sortOrder)) {
- orderBy = Provider.LeaderColumns.DEFAULT_SORT_ORDER;
- } else {
- orderBy = sortOrder;
- }
- // Get the database and run the query
- SQLiteDatabase db = mOpenHelper.getReadableDatabase();
- Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);
- // Tell the cursor what uri to watch, so it knows when its source data changes
- c.setNotificationUri(getContext().getContentResolver(), uri);
- return c;
- }
- @Override
- public String getType(Uri uri) {
- switch (sUriMatcher.match(uri)) {
- case LEADERS:
- return Provider.CONTENT_TYPE;
- case LEADER_ID:
- return Provider.CONTENT_ITEM_TYPE;
- default:
- throw new IllegalArgumentException("Unknown URI " + uri);
- }
- }
- @Override
- public Uri insert(Uri uri, ContentValues initialValues) {
- // Validate the requested uri
- if (sUriMatcher.match(uri) != LEADERS) {
- throw new IllegalArgumentException("Unknown URI " + uri);
- }
- ContentValues values;
- if (initialValues != null) {
- values = new ContentValues(initialValues);
- } else {
- values = new ContentValues();
- }
- // Make sure that the fields are all set
- if (values.containsKey(Provider.LeaderColumns.NAME) == false) {
- values.put(Provider.LeaderColumns.NAME, "");
- }
- if (values.containsKey(Provider.LeaderColumns.TITLE) == false) {
- values.put(Provider.LeaderColumns.TITLE, "");
- }
- if (values.containsKey(Provider.LeaderColumns.LEVEL) == false) {
- values.put(Provider.LeaderColumns.LEVEL, 0);
- }
- SQLiteDatabase db = mOpenHelper.getWritableDatabase();
- long rowId = db.insert(Provider.LeaderColumns.TABLE_NAME, Provider.LeaderColumns.NAME, values);
- if (rowId > 0) {
- Uri noteUri = ContentUris.withAppendedId(Provider.LeaderColumns.CONTENT_URI, rowId);
- getContext().getContentResolver().notifyChange(noteUri, null);
- return noteUri;
- }
- throw new SQLException("Failed to insert row into " + uri);
- }
- @Override
- public int delete(Uri uri, String where, String[] whereArgs) {
- SQLiteDatabase db = mOpenHelper.getWritableDatabase();
- int count;
- switch (sUriMatcher.match(uri)) {
- case LEADERS:
- count = db.delete(Provider.LeaderColumns.TABLE_NAME, where, whereArgs);
- break;
- case LEADER_ID:
- String noteId = uri.getPathSegments().get(1);
- count = db.delete(Provider.LeaderColumns.TABLE_NAME, Provider.LeaderColumns._ID + "=" + noteId
- + (!TextUtils.isEmpty(where) ? " AND (" + where + ')' : ""), whereArgs);
- break;
- default:
- throw new IllegalArgumentException("Unknown URI " + uri);
- }
- getContext().getContentResolver().notifyChange(uri, null);
- return count;
- }
- @Override
- public int update(Uri uri, ContentValues values, String where, String[] whereArgs) {
- SQLiteDatabase db = mOpenHelper.getWritableDatabase();
- int count;
- switch (sUriMatcher.match(uri)) {
- case LEADERS:
- count = db.update(Provider.LeaderColumns.TABLE_NAME, values, where, whereArgs);
- break;
- case LEADER_ID:
- String noteId = uri.getPathSegments().get(1);
- count = db.update(Provider.LeaderColumns.TABLE_NAME, values, Provider.LeaderColumns._ID + "=" + noteId
- + (!TextUtils.isEmpty(where) ? " AND (" + where + ')' : ""), whereArgs);
- break;
- default:
- throw new IllegalArgumentException("Unknown URI " + uri);
- }
- getContext().getContentResolver().notifyChange(uri, null);
- return count;
- }
- static {
- sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
- sUriMatcher.addURI(Provider.LeaderColumns.AUTHORITY, "leaders", LEADERS);
- sUriMatcher.addURI(Provider.LeaderColumns.AUTHORITY, "leaders/#", LEADER_ID);
- sLeadersProjectionMap = new HashMap<String, String>();
- sLeadersProjectionMap.put(Provider.LeaderColumns._ID, Provider.LeaderColumns._ID);
- sLeadersProjectionMap.put(Provider.LeaderColumns.NAME, Provider.LeaderColumns.NAME);
- sLeadersProjectionMap.put(Provider.LeaderColumns.TITLE, Provider.LeaderColumns.TITLE);
- sLeadersProjectionMap.put(Provider.LeaderColumns.LEVEL, Provider.LeaderColumns.LEVEL);
- }
- }
对programmer表进行增删改查操作的ContentProvider类:
ProgrammerProvider.java
- package com.jacp.demo.provider;
- import java.util.HashMap;
- import android.content.ContentProvider;
- import android.content.ContentUris;
- import android.content.ContentValues;
- import android.content.UriMatcher;
- import android.database.Cursor;
- import android.database.SQLException;
- import android.database.sqlite.SQLiteDatabase;
- import android.database.sqlite.SQLiteQueryBuilder;
- import android.net.Uri;
- import android.text.TextUtils;
- import com.jacp.database.DatabaseHelper;
- /**
- * 对programmer表进行操作的ContentProvider
- * @author jacp
- *
- */
- public class ProgrammerProvider extends ContentProvider {
- private static HashMap<String, String> sprogrammersProjectionMap;
- private static final int PROGRAMMERS = 1;
- private static final int PROGRAMMERS_ID = 2;
- private static final UriMatcher sUriMatcher;
- private DatabaseHelper mOpenHelper;
- @Override
- public boolean onCreate() {
- mOpenHelper = new DatabaseHelper(getContext());
- return true;
- }
- @Override
- public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
- String sortOrder) {
- SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
- qb.setTables(Provider.ProgrammerColumns.TABLE_NAME);
- switch (sUriMatcher.match(uri)) {
- case PROGRAMMERS:
- qb.setProjectionMap(sprogrammersProjectionMap);
- break;
- case PROGRAMMERS_ID:
- qb.setProjectionMap(sprogrammersProjectionMap);
- qb.appendWhere(Provider.ProgrammerColumns._ID + "=" + uri.getPathSegments().get(1));
- break;
- default:
- throw new IllegalArgumentException("Unknown URI " + uri);
- }
- // If no sort order is specified use the default
- String orderBy;
- if (TextUtils.isEmpty(sortOrder)) {
- orderBy = Provider.ProgrammerColumns.DEFAULT_SORT_ORDER;
- } else {
- orderBy = sortOrder;
- }
- // Get the database and run the query
- SQLiteDatabase db = mOpenHelper.getReadableDatabase();
- Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);
- // Tell the cursor what uri to watch, so it knows when its source data changes
- c.setNotificationUri(getContext().getContentResolver(), uri);
- return c;
- }
- @Override
- public String getType(Uri uri) {
- switch (sUriMatcher.match(uri)) {
- case PROGRAMMERS:
- return Provider.CONTENT_TYPE;
- case PROGRAMMERS_ID:
- return Provider.CONTENT_ITEM_TYPE;
- default:
- throw new IllegalArgumentException("Unknown URI " + uri);
- }
- }
- @Override
- public Uri insert(Uri uri, ContentValues initialValues) {
- // Validate the requested uri
- if (sUriMatcher.match(uri) != PROGRAMMERS) {
- throw new IllegalArgumentException("Unknown URI " + uri);
- }
- ContentValues values;
- if (initialValues != null) {
- values = new ContentValues(initialValues);
- } else {
- values = new ContentValues();
- }
- // Make sure that the fields are all set
- if (values.containsKey(Provider.ProgrammerColumns.NAME) == false) {
- values.put(Provider.ProgrammerColumns.NAME, "");
- }
- if (values.containsKey(Provider.ProgrammerColumns.AGE) == false) {
- values.put(Provider.ProgrammerColumns.AGE, 0);
- }
- SQLiteDatabase db = mOpenHelper.getWritableDatabase();
- long rowId = db.insert(Provider.ProgrammerColumns.TABLE_NAME, Provider.ProgrammerColumns.NAME, values);
- if (rowId > 0) {
- Uri noteUri = ContentUris.withAppendedId(Provider.ProgrammerColumns.CONTENT_URI, rowId);
- getContext().getContentResolver().notifyChange(noteUri, null);
- return noteUri;
- }
- throw new SQLException("Failed to insert row into " + uri);
- }
- @Override
- public int delete(Uri uri, String where, String[] whereArgs) {
- SQLiteDatabase db = mOpenHelper.getWritableDatabase();
- int count;
- switch (sUriMatcher.match(uri)) {
- case PROGRAMMERS:
- count = db.delete(Provider.ProgrammerColumns.TABLE_NAME, where, whereArgs);
- break;
- case PROGRAMMERS_ID:
- String noteId = uri.getPathSegments().get(1);
- count = db.delete(Provider.ProgrammerColumns.TABLE_NAME, Provider.ProgrammerColumns._ID + "=" + noteId
- + (!TextUtils.isEmpty(where) ? " AND (" + where + ')' : ""), whereArgs);
- break;
- default:
- throw new IllegalArgumentException("Unknown URI " + uri);
- }
- getContext().getContentResolver().notifyChange(uri, null);
- return count;
- }
- @Override
- public int update(Uri uri, ContentValues values, String where, String[] whereArgs) {
- SQLiteDatabase db = mOpenHelper.getWritableDatabase();
- int count;
- switch (sUriMatcher.match(uri)) {
- case PROGRAMMERS:
- count = db.update(Provider.ProgrammerColumns.TABLE_NAME, values, where, whereArgs);
- break;
- case PROGRAMMERS_ID:
- String noteId = uri.getPathSegments().get(1);
- count = db.update(Provider.ProgrammerColumns.TABLE_NAME, values, Provider.ProgrammerColumns._ID + "=" + noteId
- + (!TextUtils.isEmpty(where) ? " AND (" + where + ')' : ""), whereArgs);
- break;
- default:
- throw new IllegalArgumentException("Unknown URI " + uri);
- }
- getContext().getContentResolver().notifyChange(uri, null);
- return count;
- }
- static {
- sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
- sUriMatcher.addURI(Provider.ProgrammerColumns.AUTHORITY, "programmers", PROGRAMMERS);
- sUriMatcher.addURI(Provider.ProgrammerColumns.AUTHORITY, "programmers/#", PROGRAMMERS_ID);
- sprogrammersProjectionMap = new HashMap<String, String>();
- sprogrammersProjectionMap.put(Provider.ProgrammerColumns._ID, Provider.ProgrammerColumns._ID);
- sprogrammersProjectionMap.put(Provider.ProgrammerColumns.NAME, Provider.ProgrammerColumns.NAME);
- sprogrammersProjectionMap.put(Provider.ProgrammerColumns.AGE, Provider.ProgrammerColumns.AGE);
- }
- }
保存leader表的数据对象:
Leader.java
- package com.jacp.pojos;
- public class Leader {
- public String name;
- public String title;
- public int level;
- }
保存Programmer表的数据对象:
Programmer.java
- package com.jacp.pojos;
- public class Programmer {
- public String name;
- public int age;
- }
Activity测试:
- package com.jacp.demo;
- import android.app.Activity;
- import android.content.ContentValues;
- import android.database.Cursor;
- import android.net.Uri;
- import android.os.Bundle;
- import android.text.TextUtils;
- import android.util.Log;
- import com.jacp.demo.provider.Provider;
- import com.jacp.pojos.Leader;
- import com.jacp.pojos.Programmer;
- public class ContentProviderDemoActivity extends Activity {
- private static final String TAG = "ProviderActivity";
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- testLeader();
- testProgrammer();
- }
- private void testProgrammer() {
- Programmer p = new Programmer();
- p.name = "jacp";
- p.age = 99;
- int id = insertProgrammer(p);
- queryProgrammer(id);
- }
- private int insertProgrammer(Programmer programmer) {
- ContentValues values = new ContentValues();
- values.put(Provider.ProgrammerColumns.NAME, programmer.name);
- values.put(Provider.ProgrammerColumns.AGE, programmer.age);
- Uri uri = getContentResolver().insert(Provider.ProgrammerColumns.CONTENT_URI, values);
- Log.i(TAG, "insert uri="+uri);
- String lastPath = uri.getLastPathSegment();
- if (TextUtils.isEmpty(lastPath)) {
- Log.i(TAG, "insert failure!");
- } else {
- Log.i(TAG, "insert success! the id is " + lastPath);
- }
- return Integer.parseInt(lastPath);
- }
- private void queryProgrammer(int id) {
- Cursor c = getContentResolver().query(Provider.ProgrammerColumns.CONTENT_URI, new String[] { Provider.ProgrammerColumns.NAME, Provider.ProgrammerColumns.AGE }, Provider.ProgrammerColumns._ID + "=?", new String[] { id + "" }, null);
- if (c != null && c.moveToFirst()) {
- Programmer p = new Programmer();
- p.name = c.getString(c.getColumnIndexOrThrow(Provider.ProgrammerColumns.NAME));
- p.age = c.getInt(c.getColumnIndexOrThrow(Provider.ProgrammerColumns.AGE));
- c.close(); // 用完Cursor要释放资源,如果Cursor没有关闭系统会打出Error级别的Log
- Log.i(TAG, "programmer.name="+p.name+"---programmer.age="+p.age);
- } else {
- Log.i(TAG, "query failure!");
- }
- }
- private void testLeader() {
- Leader leader = new Leader();
- leader.name = "jacky";
- leader.title = "CTO";
- leader.level = 30;
- int id = insertLeader(leader);
- queryLeader(id);
- }
- private int insertLeader(Leader leader) {
- ContentValues values = new ContentValues();
- values.put(Provider.LeaderColumns.NAME, leader.name);
- values.put(Provider.LeaderColumns.TITLE, leader.title);
- values.put(Provider.LeaderColumns.LEVEL, leader.level);
- Uri uri = getContentResolver().insert(Provider.LeaderColumns.CONTENT_URI, values);
- Log.i(TAG, "insert uri="+uri);
- String lastPath = uri.getLastPathSegment();
- if (TextUtils.isEmpty(lastPath)) {
- Log.i(TAG, "insert failure!");
- } else {
- Log.i(TAG, "insert success! the id is " + lastPath);
- }
- return Integer.parseInt(lastPath);
- }
- private void queryLeader(int id) {
- Cursor c = getContentResolver().query(Provider.LeaderColumns.CONTENT_URI, new String[] { Provider.LeaderColumns.NAME, Provider.LeaderColumns.TITLE, Provider.LeaderColumns.LEVEL }, Provider.LeaderColumns._ID + "=?", new String[] { id + "" }, null);
- if (c != null && c.moveToFirst()) {
- Leader leader = new Leader();
- leader.name = c.getString(c.getColumnIndexOrThrow(Provider.LeaderColumns.NAME));
- leader.title = c.getString(c.getColumnIndexOrThrow(Provider.LeaderColumns.TITLE));
- leader.level = c.getInt(c.getColumnIndexOrThrow(Provider.LeaderColumns.LEVEL));
- Log.i(TAG, "leader.name="+leader.name+"---leader.title="+leader.title+"---leader.level="+leader.level);
- } else {
- Log.i(TAG, "query failure!");
- }
- }
- }
Manifest.xml文件中的注册(要注意的地方,下面已标注):
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.jacp.demo"
- android:versionCode="1"
- android:versionName="1.0" >
- <uses-sdk android:minSdkVersion="8" />
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name=".ContentProviderDemoActivity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <!-- 这个地方的两个provider的authories要不一样,否则找不到对应ContentProvider处理出现 java.lang.IllegalArgumentException: Unknown URI异常 -->
- <provider android:name=".provider.ProgrammerProvider"
- android:authorities="com.jacp.provider.demo.programmer" />
- <provider android:name=".provider.LeaderProvider"
- android:authorities="com.jacp.provider.demo.leader" />
- </application>
- </manifest>
demo下载地址:http://download.csdn.net/detail/maylian7700/4150144
如有遗漏不当之处,欢迎批评指正!
实现多个ContentProvider对多张表进行操作的更多相关文章
- android 玩转ContentProvider之二--实现多个ContentProvider对多张表进行操作
SQLite数据库直接操作类: DatabaseHelper.java package com.jacp.database; import android.content.Context; impor ...
- oracle中查找某用户执行某张表的操作操作记录
转载:http://www.cnblogs.com/nizuimeiabc1/p/9441937.html 1,首先查找表的操作记录 select * from v$sqlarea a where a ...
- MySQL 查询多张表中相同字段的最大值
MySql : 有N张表,N未知,每张表都有一个字段(id),每张表的字段结构不完全一样,如何查询所有表里面所有id的最大值?如下图所示: 对上面三张表进行操作的话,结果应该为:9 SQL语句: se ...
- MySQL实现两张表数据的同步
有两张表A和B,要求往A里面插入一条记录的同时要向B里面也插入一条记录,向B里面插入一条记录的同时也向A插入一条记录.两张表的结构不同,需要将其中几个字段对应起来.可以用下面的触发器实现. 表A的触发 ...
- 将一张表的数据,拷贝到另一张表中sql
两张表的字段一样 create table 目标表 as select * from 原表;
- (转载)详解网络传输中的三张表,MAC地址表、ARP缓存表以及路由表
郑重声明:原文转载于http://dengqi.blog.51cto.com/5685776/1223132 向好文章致敬!!! 一:MAC地址表详解 说到MAC地址表,就不得不说一下交换机的工作原理 ...
- Azure SQL Database (21) 将整张表都迁移到Azure Stretch Database里
<Windows Azure Platform 系列文章目录> Azure SQL Database (19) Stretch Database 概览 Azure SQL Da ...
- 在SqlServer2008R2中,在一张表上加上insert、update、delete触发器(带游标)
在日常工作中,在SqlServer2008R2中,需要向一张表上加上触发器,监控插入.更新.删除. --一个触发器内三种INSERT,UPDATE,DELETE状态 IF exists(select ...
- 十几张表的join(千万级/百万级表) 7hours-->5mins
================START============================== 来了一个mail说是job跑得很慢,调查下原因 先来看下sql: SELECT h.order_ ...
随机推荐
- 一步一步理解 Java 企业级应用的可扩展性
摘要:本文主要介绍如何理解 Java 应用的扩展方式以及不同类型的扩展技术和具体技巧,介绍一些有关 Java 企业级应用的一般扩展策略. 老实说,"可扩展性"是个全面且详尽的话题, ...
- DJANGO不同应用之间的用户迁移
因为重新规划新的项目,数据库表结构和以前不一定了,但是想保存以前的很多用户认证方面的东东. 于是看了一下DJANGO的导入导出功能. ~~~~~~~~~~~~~~~~~~~ 数据导入: python ...
- Microsd卡中植入NFC技术设计
NFC(Near Field Communication,近距离通信),是基于RFID技术发展起来的一种应用在手机上的近距离无线通信技术,主要应用在以下三种模式: 卡模拟状态:手机作为支付工具,可以模 ...
- 14.6.3.3 Making the Buffer Pool Scan Resistant
14.6.3.3 Making the Buffer Pool Scan Resistant 相比使用一个严格的LRU算法,InnoDB 使用一个技术来最小化数据总量 带入到buffer pool 而 ...
- 如何实现View上添加标签
效果图: 利用 https://github.com/linger1216/labelview 类库来实现 具体代码 问度娘. {LabelView label = new LabelView(thi ...
- poj 2068 Nim(博弈树)
Nim Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1501 Accepted: 845 Description Le ...
- Java 集合框架 ArrayList 源码剖析
总体介绍 ArrayList实现了List接口,是顺序容器,即元素存放的数据与放进去的顺序相同,允许放入null元素,底层通过数组实现.除该类未实现同步外,其余跟Vector大致相同.每个ArrayL ...
- NYOJ 14 贪心解题报告
会场安排问题 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描述 学校的小礼堂每天都会有许多活动,有时间这些活动的计划时间会发生冲突,需要选择出一些活动进行举办.小刘的工 ...
- java读取图片的(尺寸、拍摄日期、标记)等EXIF信息
1.metadata-extractor是 处理图片EXIF信息的开源项目,最新代码及下载地址:https://github.com/drewnoakes/metadata-extractor 2.本 ...
- 了解各种AA特性
AA(Anti-Aliasing)抗锯齿想必不少玩家在游戏画质设定中经常会遇到,说通俗一点AA抗锯齿的作用:将图像边缘及其两侧的像素颜色进行混 合,然后用新生成的具有混合特性的点来替换原来位置上... ...