Saturday, 15 June 2013

Installing Android App to SD Card From Titanium

- Android apps are installed by default to the device's internal storage. But that Limited memory space can filled fast and quick in older devices .

- You can configure your Titanium apps to install to the SD card.

- To do so, you need to modify the AndroidManifest.xml configuration file.
Titanium makes this easy: you simply update your tiapp.xml file and Studio will take care of creating the necessary manifest file.
Locate the <android> node near the end of that file.
You'll need to add a couple of properties and tags. When you're done, it should look like this:

Now Build and Deploy your app to Device.

Let's go over that code, because you can control a few options. First, the <tool-api-level> node specifies the version of the Android development tools that will be used to compile your app's code. At minimum, you must specify version 8. Higher (newer) versions aren't necessary for installing to the SD card, but perhaps offer other benefits.
Next, is the <manifest> node and the <code>android:installLocation</code> property. You'd choose one of these values for that property:
  • android:installLocation="preferExternal" -- specifies that you prefer your app to install to the SD card, but if one isn't present the app can be installed to internal storage.
  • android:installLocation="auto" – specifies that the phone's configuration will determine the installation location. Generally, your app will be installed to internal storage if sufficient space is available. In that case, users could still move your app by opening Settings > Applications > Manage applications, tapping your app, and tapping Move to SD card.
  • android:installLocation="internalOnly" – which specifies that your app cannot be installed to the SD card. See the Android docs for the various reasons why you might choose this option.
Finally, you need to add the <uses-sdk> tag within the <manifest> node. This tag specifies that your app requires Google's version 7 or newer APIs — in other words, the phone must be running Android 2.1 Update 1 or newer. That pretty much covers all the newer phones, but will exclude some older devices. On those phones, your app will install to the internal storage.

No comments:

Post a Comment