WEB开发网
开发学院手机开发Android 开发 Android 数据存储之 SQLite嵌入式数据库 阅读

Android 数据存储之 SQLite嵌入式数据库

 2010-03-26 15:43:00 来源:WEB开发网   
核心提示:String.valueOf(maxCount) };Cursor cursor = this.openHelper.getReadableDatabase().rawQuery(sql,selectionArgs);return cursor;}}5.编写测试类编写一个针对ContactsService的测试类,测试

String.valueOf(maxCount) };

Cursor cursor = this.openHelper.getReadableDatabase().rawQuery(sql,

selectionArgs);

return cursor;

}

}

5.编写测试类

编写一个针对ContactsService的测试类,测试ContactsService类中的各个方法是否正确。

package com.changcheng.sqlite.test;

import java.util.List;

import com.changcheng.sqlite.MyOpenHelper;

import com.changcheng.sqlite.entity.Contact;

import com.changcheng.sqlite.service.ContactsService;

import android.database.Cursor;

import android.test.AndroidTestCase;

import android.util.Log;

public class ContactsServiceTest extends AndroidTestCase {

private static final String TAG = "ContactsServiceTest";

// 测试创建表

public void testCreateTable() throws Throwable {

MyOpenHelper openHelper = new MyOpenHelper(this.getContext());

openHelper.getWritableDatabase();

}

// 测试save

public void testSave() throws Throwable {

ContactsService contactsService = new ContactsService(this.getContext());

Contact contact1 = new Contact(null, "tom", "13898679876");

Contact contact2 = new Contact(null, "lili", "13041094909");

Contact contact3 = new Contact(null, "jack", "13504258899");

Contact contact4 = new Contact(null, "heary", "1335789789");

contactsService.save(contact1);

contactsService.save(contact2);

contactsService.save(contact3);

contactsService.save(contact4);

}

// 测试find

public void testFind() throws Throwable {

ContactsService contactsService = new ContactsService(this.getContext());

Contact contact = contactsService.find(1);

Log.i(TAG, contact.toString());

}

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

Tags:Android 数据 存储

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