WEB开发网
开发学院手机开发Android 开发 Android 模拟器操作演练 阅读

Android 模拟器操作演练

 2010-02-20 17:15:00 来源:WEB开发网   
核心提示:/* - DataProvider.java 程式码--*/package com.misoo.pkrr;import android.content.ContentProvider;import android.content.ContentValues;import android.content.Context;

/* ----- DataProvider.java 程式码------*/

package com.misoo.pkrr;

import android.content.ContentProvider;

import android.content.ContentValues;

import android.content.Context;

import android.database.Cursor;

import android.database.SQLException;

import android.database.sqlite.SQLiteDatabase;

import android.database.sqlite.SQLiteOpenHelper;

import android.net.Uri;

import android.util.Log;

public class DataProvider extends ContentProvider {

private static final String DATABASE_NAME = "StudNewDB";

private static final int DATABASE_VERSION = 2;

private static final String TABLE_NAME = "StudTable";

private static class DatabaseHelper extends SQLiteOpenHelper {

DatabaseHelper(Context context) {

super(context, DATABASE_NAME, null, DATABASE_VERSION); }

@Override public void onCreate(SQLiteDatabase db) {

db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + "stud_no"

+ " TEXT," + "stud_name" + " TEXT" + ");");

String sql_1 = "insert into " + TABLE_NAME

+ " (stud_no, stud_name) values('S1001', 'Pam');";

String sql_2 = "insert into " + TABLE_NAME

+ " (stud_no, stud_name) values('S1002', 'Steve');";

String sql_3 = "insert into " + TABLE_NAME

+ " (stud_no, stud_name) values('S1003', 'John');";

try { db.execSQL(sql_1); db.execSQL(sql_2); db.execSQL(sql_3); }

catch (SQLException e) { Log.e("ERROR", e.toString()); }

}

@Override

public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {}

}

// ------------------------------------------------ ---------------------------------

private DatabaseHelper mOpenHelper;

@Override public boolean onCreate() {

上一页  1 2 3 4 5 6 7 8 9  下一页

Tags:Android 模拟器 操作

编辑录入:coldstar [复制链接] [打 印]
赞助商链接