我通过这段代码获取我的数据库文件
File dbFile=getDatabasePath("EdsysEyfsDB.db");
Log.v("database name checking", dbFile.toString());
我想将这个数据库文件复制到SD卡中,以便我可以对其进行某些操作。但是我无法对其进行任何操作。以下代码用于将其复制到SD卡中
if (dbFile.exists()) {
InputStream inStream = new FileInputStream(dbFile);
String file = Environment.getExternalStorageDirectory().getPath()
+"/" + "database.db";
Log.d("file name checking in dbFilecondition", file);
FileOutputStream fs = new FileOutputStream(file);
byte[] buffer = new byte[1444];
while ((byteread = inStream.read(buffer)) != -1) {
bytesum += byteread;
fs.write(buffer, 0, byteread);
}
inStream.close();
fs.close();
}
但是在这种情况下我不能进行操作。数据库文件名已经正确地出现在LogCat上了。我已经授予读写文件的权限。
但我不能在这种条件下进行操作。数据库文件名已正确出现在LogCat上。我已经授予读写文件的权限。
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
以获得对外部存储的写入权限,否则sd.canWrite()
将返回false。 - Daniel