Java android中的sqlite3_打开错误 public类DataBaseHelper扩展了SQLiteOpenHelper { 私有静态字符串DB_NAME; 私有静态字符串DB_PATH=“/data/data/com.muthu.tamil/databases/”; 私有最终上下文myContext; 私有SQLiteDatabase-myDataBase; 静止的 { DB_NAME=“aathichudi.DB”; } 公共DataBaseHelper(上下文参数上下文) { super(paramContext,DB_NAME,null,1); DB_PATH=“/data/data/”+paramContext.getPackageName()+”/databases/”; this.myContext=paramContext; } 私有布尔校验数据库() { 返回新文件(DB_路径+DB_名称).exists(); } 私有void copyDataBase() 抛出IOException { InputStream LocaliInputStream=this.myContext.getAssets().open(DB_NAME); FileOutputStream localFileOutputStream=新的FileOutputStream(DB\u路径+DB\u名称); 字节[]数组字节=新字节[1024]; while(true) { int i=localInputStream.read(arrayOfByte); 如果(i)

Java android中的sqlite3_打开错误 public类DataBaseHelper扩展了SQLiteOpenHelper { 私有静态字符串DB_NAME; 私有静态字符串DB_PATH=“/data/data/com.muthu.tamil/databases/”; 私有最终上下文myContext; 私有SQLiteDatabase-myDataBase; 静止的 { DB_NAME=“aathichudi.DB”; } 公共DataBaseHelper(上下文参数上下文) { super(paramContext,DB_NAME,null,1); DB_PATH=“/data/data/”+paramContext.getPackageName()+”/databases/”; this.myContext=paramContext; } 私有布尔校验数据库() { 返回新文件(DB_路径+DB_名称).exists(); } 私有void copyDataBase() 抛出IOException { InputStream LocaliInputStream=this.myContext.getAssets().open(DB_NAME); FileOutputStream localFileOutputStream=新的FileOutputStream(DB\u路径+DB\u名称); 字节[]数组字节=新字节[1024]; while(true) { int i=localInputStream.read(arrayOfByte); 如果(i),java,android,sqlite,Java,Android,Sqlite,仅当数据库未在模拟器或设备中创建时,才会产生此错误。您可以检查数据库是否在IDE DDMS/file_explorer(/data/data/Ur_pkg_name/databases/Ur_db_name)中创建 报告了与此问题相关的错误: 我遇到了一些人们提出的解决方案/变通方法,包括以下内容: 如果在清单文件中使用sharedUserId,则更改应用程序的sharedUserId并重新安装应用程序可能会起作用,因为它没有写入SQLite数据库所需的所有权 编辑清单文件可以再次消除错误。在清

仅当数据库未在模拟器或设备中创建时,才会产生此错误。您可以检查数据库是否在IDE DDMS/file_explorer(/data/data/Ur_pkg_name/databases/Ur_db_name)中创建

报告了与此问题相关的错误:

我遇到了一些人们提出的解决方案/变通方法,包括以下内容:

如果在清单文件中使用sharedUserId,则更改应用程序的sharedUserId并重新安装应用程序可能会起作用,因为它没有写入SQLite数据库所需的所有权

编辑清单文件可以再次消除错误。在清单中,请确保您输入了正确的min sdk版本。如果代码的左栏中有感叹号指示符告诉我您的错误,则可以通过检查清单文件来确保您的min sdk版本正常


我希望这些解决方案中的一个也能对您起作用。

您是否试图将数据库复制到文件或其他内容中?我试图将文件信息复制到数据库中在构造函数中,您将
DB_路径设置为
com.muthu,tamil
的某个内容,这似乎是错误的-请注意
muthu
后面的逗号。但是,您不应该使用您的代码中有硬编码的绝对路径。请改为尝试。您能从中发布完整的错误日志吗LogCat@cyroxx我尝试了paramContext.getPackageName(),但我得到了相同的错误
          public class DataBaseHelper extends SQLiteOpenHelper
          {
              private static String DB_NAME;
              private static String DB_PATH = "/data/data/com.muthu.tamil/databases/";
              private final Context myContext;
              private SQLiteDatabase myDataBase;

             static
              {
                  DB_NAME = "aathichudi.db";
              }

  public DataBaseHelper(Context paramContext)
  {
    super(paramContext, DB_NAME, null, 1);
    DB_PATH = "/data/data/" + paramContext.getPackageName() + "/databases/";
    this.myContext = paramContext;
  }

  private boolean checkDataBase()
  {
    return new File(DB_PATH + DB_NAME).exists();
  }

  private void copyDataBase()
    throws IOException
  {
    InputStream localInputStream = this.myContext.getAssets().open(DB_NAME);
    FileOutputStream localFileOutputStream = new FileOutputStream(DB_PATH + DB_NAME);
    byte[] arrayOfByte = new byte[1024];
    while (true)
    {
      int i = localInputStream.read(arrayOfByte);
      if (i <= 0)
      {
        localFileOutputStream.flush();
        localFileOutputStream.close();
        localInputStream.close();
        return;
      }
      localFileOutputStream.write(arrayOfByte, 0, i);
    }
  }




  public void createDataBase()
    throws IOException
  {
    if (checkDataBase())
      new File(DB_PATH + DB_NAME).delete();
    getReadableDatabase();
    close();
    try
    {
      copyDataBase();
      return;
    }
    catch (IOException localIOException)
    {
    }
    throw new Error("Error copying database");
  }

  public Cursor getData(String paramString)
  {
    return this.myDataBase.rawQuery(paramString, null);
  }

  public void onCreate(SQLiteDatabase paramSQLiteDatabase)
  {
  }

  public void onUpgrade(SQLiteDatabase paramSQLiteDatabase, int paramInt1, int paramInt2)
  {
  }

  public void openDataBase()
    throws SQLException
  {
    this.myDataBase = SQLiteDatabase.openDatabase(DB_PATH + DB_NAME, null, 1);
  }
sqlite3_open_v2("/data/data/com.muthu,tamil/databases/aathichudi.db", &handle, 1, NULL)
failed sqlite returned: error code = 14, msg = cannot open file at source line 25467