开发者

How can I have an Android app install media to the SDcard?

And when I say "install" I mean "move upon installation". I want to package a movie file with an .apk, but it's kind of big for internal storage (at least on older phones) as it is ~10mb.

Since there is no "run this custom code when you install" feature (reasonable), I can't save to the SDcard the normal way... right?

There's always the option of having the app download the movie and save it to the SDcard when the user first launches, but then they can't watch the movie until it's done downloading, and that doesn't feel elegant since they just finished downloading the app and now have to wait again.

I know about installing the entire app to the SDcard, but that 开发者_运维百科only works for 2.2+, eh? Enough phones are still running 2.1 that I want to support those.


have you looked at http://developer.android.com/guide/appendix/install-location.html

btw here goes the code add this to your manifest file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:installLocation="preferExternal"
    ... >

Note: The ability for your application to install on the external storage is a feature available only on devices running API Level 8 (Android 2.2) or greater. Existing applications that were built prior to API Level 8 will always install on the internal storage and cannot be moved to the external storage (even on devices with API Level 8). However, if your application is designed to support an API Level lower than 8, you can choose to support this feature for devices with API Level 8 or greater and still be compatible with devices using an API Level lower than 8.


Look up the app install location information in the manifest. You can use preferExternal. Obviously, this will only work on Android 2.2, previous versions will always install to internal storage (unless they're using a custom ROM).


I've seen several android apps offer something similar, via separate Marketplace downloads, space physics is a good example. Not really elegant, but it works well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜