باسلام
این برنامه خطادر بازکردن بانک میذه من تو چه مسیری دنبال بانک باشم؟؟؟
public class myDB {
//SQLite database
private SQLiteDatabase moDB;
private final static String CONST_DB_PATH="/SMART-BUS";
private final static String CONST_DB_NAME="/Database.db3";
private String mstrCurDBPath;
protected void onDestroy()
{
CloseDatabase();
}
public SQLiteDatabase GetDB()
{
return moDB;
}
public void CloseDatabase()
{
if(moDB!=null)
{
if (moDB.isOpen())
{
moDB.close();
}
}
}
public String GetDBPath()
{
//String strDBPath ;
//strDBPath= android.os.Environment
// .getExternalStorageDirectory().getAbsolutePath()
// + CONST_DB_PATH+CONST_DB_NAME;
//strDBPath = android.os.Environment.getExternalStorageDirectory ().getAbsolutePath()
// + CONST_DB_PATH+CONST_DB_NAME;
return mstrCurDBPath;
}
public SQLiteDatabase OpenDatabase()
{
String strDBPath,strRoot ;
File oDir;
try
{
moDB=null;
strDBPath = android.os.Environment.getExternalStorageDirectory ().getAbsolutePath()
+ CONST_DB_PATH+CONST_DB_NAME;
oDir = new File(strDBPath);
if (oDir.exists()==false)
{
strDBPath="/sdcard"+CONST_DB_PATH+CONST_DB_NAME;
oDir = new File(strDBPath);
if (oDir.exists()==false)
{
strDBPath ="/flash"+CONST_DB_PATH+CONST_DB_NAME;
oDir = new File(strDBPath);
if (oDir.exists()==false)
{
strDBPath = "/mnt/sdcard" + CONST_DB_PATH+CONST_DB_NAME;
oDir = new File(strDBPath);
if (oDir.exists()==false)
{
strDBPath = "/LocalDisk" + CONST_DB_PATH+CONST_DB_NAME;
if (oDir.exists()==false)
{
strDBPath = "/local" + CONST_DB_PATH+CONST_DB_NAME;
}
}
}
}
}
mstrCurDBPath=strDBPath;
moDB = SQLiteDatabase.openOrCreateDatabase(strDBPath, null);
}catch (Exception e)
{
}
return moDB;
}