我想这个一整天,但我给WRITE_EXTERNAL存储许可后还我仍然得到这个权限被拒绝的错误。 现在,我想这个程序我的手机。 同样,相同的权限错误是logcat的。 我在此website.It许多可用的代码试图总是fails.Guide我一些tuorials拷贝数据库到SD卡
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = "data/com.sri.tut/databases/image_storage.db";
String backupDBPath = "image_storage.db";
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
if (currentDB.exists()) {
FileChannel src = new FileInputStream(currentDB).getChannel();
FileChannel dst = new FileOutputStream(backupDB).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
}
}
} catch (Exception e) {
}
这是我的logcat的输出。
09-14 08:36:07.663: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:09.413: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:09.963: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:10.203: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:10.654: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:10.854: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:11.083: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:11.283: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:11.683: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:11.934: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:12.224: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:12.463: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:12.734: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:13.053: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:13.413: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:13.694: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:13.914: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:14.303: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:14.563: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:36:14.804: ERROR/Movedb(12336): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:37:42.253: WARN/PackageManager(67): Mounting container com.sri.copydata-1
09-14 08:37:45.634: WARN/InputManagerService(67): Got RemoteException sending setActive(false) notification to pid 12336 uid 10053
09-14 08:37:52.463: WARN/PackageManager(67): Code path for pkg : com.sri.copydata changing from /mnt/asec/com.sri.copydata-2/pkg.apk to /mnt/asec/com.sri.copydata-1/pkg.apk
09-14 08:37:52.463: WARN/PackageManager(67): Resource path for pkg : com.sri.copydata changing from /mnt/asec/com.sri.copydata-2/pkg.apk to /mnt/asec/com.sri.copydata-1/pkg.apk
09-14 08:38:00.773: WARN/RecognitionManagerService(67): no available voice recognition services found
09-14 08:42:05.613: WARN/PackageManager(67): Mounting container com.sri.copydata-2
09-14 08:42:11.294: WARN/InputManagerService(67): Got RemoteException sending setActive(false) notification to pid 13273 uid 10053
09-14 08:42:20.063: WARN/PackageManager(67): Code path for pkg : com.sri.copydata changing from /mnt/asec/com.sri.copydata-1/pkg.apk to /mnt/asec/com.sri.copydata-2/pkg.apk
09-14 08:42:20.063: WARN/PackageManager(67): Resource path for pkg : com.sri.copydata changing from /mnt/asec/com.sri.copydata-1/pkg.apk to /mnt/asec/com.sri.copydata-2/pkg.ap
09-14 08:42:29.033: WARN/RecognitionManagerService(67): no available voice recognition services found
09-14 08:42:51.374: ERROR/Movedb(14575): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)
09-14 08:43:14.043: ERROR/Movedb(14575): Error in Copyingjava.io.FileNotFoundException: /data/data/com.sri.assign/databases/AssignmentsDB (Permission denied)