androidcopy
发布时间: 2025-09-07 07:25:35
1. 如何从android手机中把自己的数据库给COPY出来
Android是有自带的类库的:SQLiteOpenHelper,使用的时候继承这个类,然后写逻辑就可以,一般使用单例模式: public synchronized static DBHelper getDBHelper(Context context) { if (helper == null) { helper = new DBHelper(context); } return helper; } private DBHelper(Context context) { super(context, "自己的数据库名", null, 数据库版本); } 使用的时候也很简单,下面是一个删除操作: public synchronized void deleteSite(String packname) { SQLiteDatabase db = getWritableDatabase(); try { db.beginTransaction(); db.delete("site", "packname=?", new String[] { packname }); db.setTransactionSuccessful(); } finally { db.endTransaction(); if (db != null) { } } }
热点内容