这是我试图实现SkyEpub Reader并向其添加书籍的代码。
public boolean makeBooksDirectory() {
boolean res;
String filePath = new String(getFilesDir().getAbsolutePath() + "/books");
Log.d("Debug", filePath);
File file = new File(filePath);
if (!file.exists()) {
res = file.mkdirs();
Log.d("Land",file.getPath());
}else {
res = false;
}
return res;
}
public boolean fileExists(String fileName) {
boolean res;
String pureName = this.removeExtention(fileName);
String targetDirectory = getFilesDir().getAbsolutePath() + "/books/"+pureName;
String targetPath = targetDirectory+"/"+ fileName;
File file = new File(targetPath);
debug(file.getAbsolutePath());
if (file.exists()) res = true;
else res = false;
return res;
}
但是当我试图运行它时,它会显示以下错误。我不明白我是否需要在任何地方制作书籍文件夹?
错误:
I/Timeline: Timeline: Activity_launch_request D/Debug: /data/user/0/com.App/files/books
08-30 19:43:34.425 15819-15819/com.App D/EPub: faild to make books directory
08-30 19:43:34.457 15819-15819/com.App D/PhoneWindow: notifyNavigationBarColor, color=0x: ff000000, token: android.view.ViewRootImplAO$WEx@4064635
08-30 19:43:34.629 15819-15819/com.App V/ViewRootImpl: Contents drawing finished : com.App/com.App.activities.EPubActivity
08-30 19:43:34.671 15819-15877/com.App E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa5d062e0