Android - Could Not Open [SQL] Database Error

前端 未结 5 619
轮回少年
轮回少年 2021-01-25 11:16

I am currently making an application for the Android SDK that will allow me to open/copy a database already made outside of the application. I was having trouble getting my prog

5条回答
  •  忘了有多久
    2021-01-25 11:58

    As far as I can remember, there is no "scratch" directory in the Android filesystem. When you call

    File file = new File("/scratch/android-sdk-linux/tools/os.sqlite");
    database = SQLiteDatabase.openOrCreateDatabase(file, null);
    

    I believe that the second statement would throw some error as the /scratch/android-sdk-linux/tools/os.sqlite filepath doesn't exist. Try calling file.mkdirs() or file.createNewFile().

提交回复
热议问题