sqlite在2.1下的异常处理解决
package com.gd.zyrs; import java.io.File; import android.content.Context; import android.content.ContextWrapper; import android.database.sqlite.SQLiteDatabase; import android.util.Log; class DatabaseContext extends ContextWrapper { private static final String DEBUG_CONTEXT = "DatabaseContext"; public DatabaseContext(Context base) { super(base); } @Override public File getDatabasePath(String fullName) { String dbfile = fullName; if (!dbfile.endsWith(".db")) { dbfile += ".db"; } File result = new File(dbfile); if (!result.getParentFile().exists()) { result.getParentFile().mkdirs(); } if (Log.isLoggable(DEBUG_CONTEXT, Log.WARN)) { Log.w(DEBUG_CONTEXT, "getDatabasePath(" + fullName + ") = " + result.getAbsolutePath()); } return result; } @Override public SQLiteDatabase openOrCreateDatabase(String name, int mode, SQLiteDatabase.CursorFactory factory) { SQLiteDatabase result = SQLiteDatabase.openOrCreateDatabase( getDatabasePath(name), null); // SQLiteDatabase result = super.openOrCreateDatabase(name, mode, // factory); if (Log.isLoggable(DEBUG_CONTEXT, Log.WARN)) { Log.w(DEBUG_CONTEXT, "openOrCreateDatabase(" + name + ",,) = " + result.getPath()); } return result; } }
就可以了
相关推荐
kevinweijc 2020-08-18
kikaylee 2020-08-18
寻常白昼 2020-08-15
shunelly 2020-08-09
liangzhouqu 2020-07-28
JessePinkmen 2020-07-26
xiaoxiaoniaoer 2020-07-21
Lexan 2020-06-22
heimicms 2020-06-14
tianyafengxin 2020-06-08
lynjay 2020-06-06
cenylon 2020-06-04
lqxqust 2020-06-03
宿舍 2020-05-29
Wonder的学习 2020-05-11
明天你好 2020-05-09
阿艾辣悟叩德 2020-05-06
致终将努力的我们 2020-05-05