Choose internal storage and external storage

What does internal storage and external storage mean in android ? Ιs external storage a micro SDcard and internal storage phone memory ? If I need to write a file for my application, which is only my application needs (the user has no work to do with this file), then where should I write my file - in internal memory or external memory?

I think, if I write my file in SDcard (external memory) then when user pull out the SDcard the application will not be able to read the file. Is it right? If it is right then writing file in external memory will not fulfill my criteria. Because, my application has to check some data in the file several times and if in that particular moment the user pulls the SDcard out, my app can't achieve its goal.

And I need to write the file permanently (but if the user uninstalls the app, then the file should be deleted). So, which way should I go?


Use Internal Storage for your purpose (as a file or as a shared pref[key-value pair] )

SD Card is not an option for you usage .

Use the android developer link which explains various storage options: http://developer.android.com/guide/topics/data/data-storage.html

Cheers, Preeya


Have a look at this blog post about the correct way to use file storage in Android.

If you need to have access to the file all the time, internal storage is the way to go. But you shouldn't use big files in internal storage because many devices are very limited in storage space.

Files get deleted automatically on external as well as on internal storage when you use the Android built-in mechanisms to create the files in the first place. That is also explained in the post.


Ιs external storage a micro SDcard and internal storage phone memory ?

micro SDcard and internal phone memory, both of them are external storage according to official Android docs.

If I need to write a file for my application, which is only my application needs (the user has no work to do with this file), then where should I write my file - in internal memory or external memory?

Save your files in Internal Storage.

And I need to write the file permanently (but if the user uninstalls the app, then the file should be deleted). So, which way should I go?

Save your files in Internal Storage.

Why because, according to Official Android Guide,

By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application, these files are removed.

Methods to save files in Internal Storage:

Both of them are in Context class

File getDir (String name, int mode)

File getFilesDir () 

But, note that many low end phones have limited internal memory . In those type of phones, even images captured using camera are automatically stored in SD card. You have to take care of such cases.

The Internal and External Storage terminology according to Google/official Android docs is quite different from what we think.

链接地址: http://www.djcxy.com/p/85136.html

上一篇: 如何在不插电的情况下访问其他应用的/ data / data目录

下一篇: 选择内部存储和外部存储