Use android.externalStorage instead of hardcoded string for android data path

This commit is contained in:
Hzj_jie
2016-09-16 10:04:51 -07:00
parent 76cef07c07
commit 3bf8b185d3

View File

@@ -1,5 +1,5 @@
-- need low-level mechnism to detect android to avoid recursive dependency
local isAndroid = pcall(require, "android")
local isAndroid, android = pcall(require, "android")
local lfs = require("libs/libkoreader-lfs")
local DataStorage = {}
@@ -9,7 +9,7 @@ function DataStorage:getDataDir()
if data_dir then return data_dir end
if isAndroid then
data_dir = "/sdcard/koreader"
data_dir = android.externalStorage() .. "/koreader"
elseif os.getenv("UBUNTU_APPLICATION_ISOLATION") then
local app_id = os.getenv("APP_ID")
local package_name = app_id:match("^(.-)_")