0

In an Android application, I need to save a JSON file in public external storage where the file won't be removed if the application is uninstalled
Public external storage allows just some special folders to save data and those folders are as following:

DIRECTORY_ALARMS  
DIRECTORY_DCIM  
DIRECTORY_DOCUMENTS  
DIRECTORY_DOWNLOADS  
DIRECTORY_MOVIES  
DIRECTORY_MUSIC  
DIRECTORY_NOTIFICATIONS  
DIRECTORY_PICTURES  
DIRECTORY_PODCASTS  
DIRECTORY_RINGTONES

All folders have their own special types of files but no general folder has been considered for other unknown types of files

I don't know where(in which folder) to put a JSON file, any suggestion?

BTW, DIRECTORY_DOCUMENTS has been added in API 19 and I need API level lower than 19

Amrutha Saj
  • 1,408
  • 16
  • 35
AndroidHV
  • 369
  • 1
  • 9
  • You can save it in external storage anywhere it will not be removed. https://developer.android.com/guide/topics/data/data-storage#filesExternal Most often, you should use external storage for user data that should be accessible to other apps and saved even if the user uninstalls your app, such as captured photos or downloaded files. Plus the files are world readable. go though the docs – Shubham AgaRwal Jul 28 '18 at 06:41
  • Sorry I can't understand, the document specifies that : **You can also save files to the external storage in an app-specific directory that the system deletes when the user uninstalls your app**, what I get is just in public place of external storage place (which I previously listed) the data will not be removed after the app is uninstalled, and other places is private even if it is external storage and will be deleted after the app is uninstalled, is't that true? – AndroidHV Jul 28 '18 at 07:13
  • I am not the expert however but external storage is categorized into two part public (World readable) private (App readable) https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String) Public: getExternalStoragePublicDirectory Private: getExternalFilesDir External Storage Root: getExternalStorageDirectory (this will access to root of external storage if mounted), Just create the folder here and write your json – Shubham AgaRwal Jul 28 '18 at 07:24
  • `You can also save files to the external storage in an app-specific directory that the system deletes when the user uninstalls your app, ` Have a look at getExternalFilesDir() for that app specific directory. – greenapps Jul 28 '18 at 09:24

0 Answers0