WEB开发网
开发学院手机开发Android 开发 Android 数据库与MapView总结 阅读

Android 数据库与MapView总结

 2010-11-05 00:54:34 来源:WEB开发网   
核心提示:public String FieldNames[][];public String FieldTypes[][];public static String NO_CREATE_TABLES = "no talbes";private String message = "";pu

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[][]) {

super(context, name, factory, version);

TableNames = tableNames;

FieldNames = fielsNames;

FieldTypes = fieldTypes;

// TODO Auto-generated constructor stub

}

@Override

public void onCreate(SQLiteDatabase db) {

if (TableNames == null) {

message = NO_CREATE_TABLES;

return;

}

for (int i = 0; i < TableNames.length; i++) {

String sql = "create table " + TableNames[i] + " (";

for (int j = 0; j < FieldNames[i].length; j++) {

sql += FieldNames[i][j] + " " + FieldTypes[i][j] + ",";

}

sql = sql.substring(0, sql.length() - 1);

sql += ")";

db.execSQL(sql);

}

}

@Override

public void onUpgrade(SQLiteDatabase db, int arg1, int arg2) {

for (int i = 0; i < TableNames[i].length(); i++) {

String sql = "DROP TABLE IF EXISTS " + TableNames[i];

db.execSQL(sql);

}

onCreate(db);

}

public void execute(String sql) throws java.sql.SQLException{

SQLiteDatabase db =this.getWritableDatabase();

db.execSQL(sql);

}

public Cursor select(String table,String[] columns,String selection,String[] selectionArgs,

String groupBy,String having,String orderBy

){SQLiteDatabase db=this.getReadableDatabase();

Cursor cursor =db.query(table, columns, selection, selectionArgs, groupBy,

上一页  24 25 26 27 28 29 30 31  下一页

Tags:Android 数据库 MapView

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