作者MiaShopgirl ( )
看板AndroidDev
标题Re: [问题] 请问外部档案安装
时间Thu Jul 12 15:41:53 2012
※ 引述《aquatear (米虫)》之铭言:
恕删
: 不过这样就没办法分辨档案新旧...
: 如果外部档案被程式设计师更新後, 使用者再去装 apk,
: 但是 sdcard 存在之前旧的外部档案
: 这样就会造成更新上的问题了~~
: 不知道有没有好的解法...
java.io.File.
lastModified()
http://developer.android.com/reference/java/io/File.html#lastModified()
Returns the
time when this file was last modified, measured in milliseconds
since January 1st, 1970, midnight. Returns 0 if the file does not exist.
: 主要的问题还是不想让使用者自己手动
: copy 外部档到 sdcard...(应该没有一个 app 是这样做)
: 因为程式本身会读取绝对路径, 也就是一个 String path,
: 所以 InputStream 他是不吃的, 这边不能改的原因,
: 是因为那个路径是透过 jni 传到底层去的, 不是在 java 上层处理的资料,
: 所以只能读取绝对路径~~
: 好怪阿 ~~ 那些 game 到底是怎麽写的呢 > <
: 应该都会有资料档存在 sdcard 的吧~ 还是都不用更新这样 > <
: 整包 apk update ?
对jni不熟,Android存取资料的地方..
除了SD path, 还有
data/data/your.package.name/cache getCacheDir().getAbsolutePath()
/files getFilesDir().getAbsolutePath()
既然路径是固定的,又担心档案本身是否被更动过,这招参考看看
public abstract FileOutputStream openFileOutput (String name, int mode)
http://goo.gl/MKpBs
Open a private file associated with this Context's application package for
writing. Creates the file if it doesn't already exist.
可以设定读写的权限 MODE_XXX
※ 编辑: MiaShopgirl 来自: 114.32.163.6 (07/12 15:49)
1F:推 gpc:mode有API LEVEL的问题 不适合做common app 07/12 17:43
喔喔,因为我自己的目标都是设定以market上大多数的使用者会用到的版本
今天正要来测这功能,熊熊看到.. Since: API Level 1
这样还有level的问题嘛@@?
http://developer.android.com/about/dashboards/index.html
目前看起来,2.1↑居多,不过通常都指定2.2 Level 8 就是~
2F:→ tacor:利用SharedPreferences,判断copy前後的变数,就不会重覆copy 07/14 06:29
※ 编辑: MiaShopgirl 来自: 114.32.163.6 (07/17 15:23)