private boolean tabbleIsExist(String tableName, SQLiteDatabase db) { LogUtils.d("DatabaseHelper", "checking tabbleIsExist " + tableName); boolean result = false; if (tableName == null) { return false; } Cursor cursor = null; try { String sql = "select count(*) as c from sqlite_master where type ='table' and name ='" + tableName.trim() + "' "; cursor = db.rawQuery(sql, null); if (cursor.moveToNext()) { int count = cursor.getInt(0); if (count > 0) { result = true; } } } catch (Exception e) { LogUtils.e("DatabaseHelper", "error in tabbleIsExist:" + e.toString()); } LogUtils.d("DatabaseHelper", "checking tabbleIsExist " + tableName + " " + result); return result; }
【推荐】100%开源!大型工业跨平台软件C++源码提供,建模,组态!
【推荐】AI 的力量,开发者的翅膀:欢迎使用 AI 原生开发工具 TRAE
【推荐】2025 HarmonyOS 鸿蒙创新赛正式启动,百万大奖等你挑战
【推荐】博客园的心动:当一群程序员决定开源共建一个真诚相亲平台