【问题标题】:Using Zumero to sync android application, change location of cache file使用 Zumero 同步 android 应用程序,更改缓存文件的位置
【发布时间】:2015-09-20 02:42:40
【问题描述】:

我正在使用 Zumero 与我的 Android 应用程序同步到 MS SQL 服务器,我的 SQLite 数据库存储在 SD 卡上。当我运行同步时,它会在更新 SQLite 数据库之前在内部存储中创建一个缓存文件。这会导致内部存储问题,并且由于存储空间不足,操作系统会在更新数据库之前删除缓存文件。如何强制应用将 SD 卡用于缓存文件?

【问题讨论】:

    标签: android sqlite caching zumero


    【解决方案1】:

    我通过替换它来工作

    context.getCacheDir().getAbsolutePath()
    

    context.getExternalCacheDir().getAbsolutePath()
    

    【讨论】:

      【解决方案2】:

      您需要将 Zumero Java 文件直接用作应用程序的一部分(在 SDK 中查找 ZumeroClient.java 等),并编辑正在使用的临时路径。将这些编译到您的应用中,而不是使用 zumero.jar(您仍然需要适当的 .so 库)。

      开箱即用,Zumero 使用 Android 上下文提供的缓存路径。您需要编辑对 native_sync() 的调用,并将最后一个参数替换为 SD 卡上的路径。

      例如

      native_sync(databasePath, encryptionKey, serverURL, dbFile, authScheme,
                  username, password, context.getCacheDir().getAbsolutePath());
      

      会变成

      native_sync(databasePath, encryptionKey, serverURL, dbFile, authScheme, 
                  username, password, myCacheDir);
      

      【讨论】:

      • 我正在使用'code' public File getCacheFolder(Context context) { File cacheDir = null; if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { cacheDir = new File(Environment.getExternalStorageDirectory(), "cachefolder"); if(!cacheDir.isDirectory()) { cacheDir.mkdirs(); } } if(!cacheDir.isDirectory()) { cacheDir = context.getCacheDir(); //获取系统缓存文件夹 } return cacheDir; 'code' 获取目录。怎样才能进入同步功能?
      猜你喜欢
      • 2011-08-05
      • 1970-01-01
      • 1970-01-01
      • 2022-10-25
      • 1970-01-01
      • 1970-01-01
      • 2020-01-03
      • 2011-06-05
      • 2014-03-13
      相关资源
      最近更新 更多