I want to make an app like linkSD2 that is responsible for moving app
That you can move the application programmatically seems to me that it is not possible, but you can define the file AndroidManifest.xml
of your application where the application would be installed, and if this only allows to be installed in the internal storage, this through the property :
android:installLocation
in which you can specify
"internalOnly"
: if the application should only be installed on the
internal storage.
"auto"
: if the application can be installed in storage
external (SD Card), but the operating system can install the application in the
internal storage by default. If internal storage is
full, the operating system installs it in external storage.
The user can move the application in the storage he chooses.
"preferExternal"
: Indicates that the application prefers to be installed in
External storage (SD Card). The user can move the application in the
storage you choose.
Example:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
...
... >
Regarding what happens if you install your application with the .apk, in the case that your application is installed in external storage, the .apk is installed there but data that the application generates such as databases, preferences , .dex, etc this is saved in internal storage.
I do not know if it stays in that format apk or change to another format or it
It divides into different fragments.
Actually it is divided, the file .apk is a packaged file, in fact you can check it by changing the extension to .zip and open it so that you can see its contents.
As an example, change the extension of my file MyApp.apk
to MyApp.zip
and this is its content:
From the configuration you can make the movement of your application to external storage (SD Card) or internal, if you have defined in your AndroidManifest.xml
:
android:installLocation="auto"
or
android:installLocation="preferExternal"