Android 数据库与MapView总结
2010-11-05 00:54:34 来源:WEB开发网return cursor;
}
public long insert(String table,String fields[],String values[]){
SQLiteDatabase db=this.getReadableDatabase();
ContentValues cv =new ContentValues();
for(int i=0;i
cv.put(fields[i], values[i]);
}
return db.insert(table,null, cv);
}
public int delete(String table,String where,String[] whereValue){
SQLiteDatabase db=this.getReadableDatabase();
return db.delete(table, where, whereValue);
}
public int update(String table,String updateFields[],String updateValues[],String where,
String[] whereValue){
SQLiteDatabase db =this.getWritableDatabase();
ContentValues cv=new ContentValues();
for(int i=0;i
cv.put(updateFields[i], updateValues[i]);
}
return db.update(table, cv, where, whereValue);
}
public String getMessage(){
return message;
}
public synchronized void close(){
super.close();
}
}
package irdc.ex10_06;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
public class MySQLiteOpenHelper extends SQLiteOpenHelper {
public String TableNames[];
public String FieldNames[][];
public String FieldTypes[][];
public static String NO_CREATE_TABLES = "no talbes";
private String message = "";
public MySQLiteOpenHelper(Context context, String name,
CursorFactory factory, int version, String tableNames[],
String fielsNames[][], String fieldTypes[][]) {
更多精彩
赞助商链接