Reputation: 992
Is there any way in Java to actually find out if your android application is installed on the SD-Card or the Internal Phone storage.
If my application is installed on the Internal Phone storage, and my application creates a text file, then the text file is also stored on the Internal Phone storage, right? So when moving the application to the SD-Card, would the text file move to the SD-Card too?
Does that make sense? =P
Thanks in advance.
Upvotes: 1
Views: 755
Reputation: 48871
Is there any way in Java to actually find out if your android application is installed on the SD-Card or the Internal Phone storage.
Look at ApplicationInfo.FLAG_EXTERNAL_STORAGE
If my application is installed on the Internal Phone storage, and my application creates a text file, then the text file is also stored on the Internal Phone storage, right?
Not necessarily - it depends what method you use to create the file. Creating internal or external files generally use completely different methods.
For example the preferred method to create internal files is to use..
openFileOutput(String name, int mode)
Similarly the preferred method for reading internal files is...
openFileInput(String name)
If the original file was moved to SD card then it wouldn't be found as openFileInput(String name)
only works for internal storage. In other words if the move process moved internal files, it would 'break' the programmer's code.
So when moving the application to the SD-Card, would the text file move to the SD-Card too?
No, creation of data files and where they are stored is independent of where the actual app is physically installed for the reason above.
Upvotes: 2