English 中文(简体)
进口数据库和机器人进口数据库中的问题
原标题:Issues in import database in android
(div) 类 = “ little” : “ 发送 ” : “ 发送 ” : “ 发送 ” : “ 发送 ” ; “ 发送 ” ; “ 发送 ” ; “ 发送 ” ; “发送 ” 。 现在尝试使用 sqlite db 。 我用 Sqlite 管理器创建了一个数据库 sqlite 文件。 我尝试了以下代码, 但如果我在设备中释放了 崩溃 。 “ 发送 ”, 显示了一个警示 。 应用程序 CheckMobile Fostatarbase 已经意外停止了, 我的 Sdk 版本为 2.2( 8) 私人空的 StoreDatabase () { {Dbile= newfile (d) 。 [dread] 。 [dread] ; “ 发送 发送 ; “ 发送 发送 发送 发送 ” (flitelex. (flead); (flead); (d).
最佳回答

没有你的滑板猫,这只是在黑暗中拍摄。

您可以尝试以另一种方式检查文件的存在 :

private static boolean checkDataBase(String dbname) {
    SQLiteDatabase checkDB = null;
    boolean exist = false;
    try {
        String db = MAIN_DB_PATH + dbname;
        checkDB = SQLiteDatabase.openDatabase(db, null,
                SQLiteDatabase.OPEN_READONLY);
    } catch (SQLiteException e) {
        Log.v("db log", "database does t exist");
    }
    if (checkDB != null) {
        exist = true;
        checkDB.close();
    }
    return exist;
}

如果 db 不存在的话, 使用另一种方法复制 db :

private static void copyDataBase(String dbname) throws IOException {
    InputStream myInput = mCtx.getAssets().open(dbname);
    String outFileName = MAIN_DB_PATH + dbname;
    OutputStream myOutput = new FileOutputStream(outFileName);
    byte[] buffer = new byte[1024];
    int length;
    while ((length = myInput.read(buffer)) > 0) {
        myOutput.write(buffer, 0, length);
    }
    myOutput.flush();
    myOutput.close();
    myInput.close();
}
问题回答

可能是由于先前版本存储在您的机器人装置中的数据库, 尝试从您的设备中删除先前的 db, 或更改代码中的数据库版本, 以便调用升级





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签