简体   繁体   中英

Is my android application installed on the SD-Card or Internal Phone storage

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM