I am having problem i have just created a simple android app.I want to know that the folder of package name i.e. com.xx.xx in Android/data as usually created when we install an app is not present on my device how to solve this problem.
Is something that i am missing in manifest i have declared only permission for write external storage and everything in manifest file is same as default.
From what I have seen the folder com.xx.xx in Android/data for the normal cases which you see only gets created if you exclusively write files to the external storage using something like getExternalFilesDir() or getExternalCacheDir() method. So unless you are writing it to the external storage you might be creating them as files stored privately by the application.
If you are looking for these files stored privately by the application, i don't think these are shown by the default file browser in an unrooted device. But in an emulator or device connected to android studio, you can use "Device File Explorer".
If you don't see its tab, go to: View --> Tool Windows --> Device File Explorer.
In the Device File Explorer, Select your device then expand: data --> data --> com.xx.xx
And within it you should be able to see the privately generated files.
Also for us to understand what you are actually using, there is no way unless you add the code of how you are writing these files you mentioned.
Related
I'm developing an app that has the functionality to upload all video and photo files to an external server, and I would like to offer the user the possibility to empty their photo and video directory...soon there is some easy way to do that? erasing everything at once
I assume your app already has a way to get access to the path to the directory you want to clear, and a permission to access the storage. Now having the path to the directory you could simply
File(pathToDirectory).list().forEach{ it.delete() }
Customize the behavior based on your needs. For example, you could recursively call the function containing the code above to clear a directory and all included subdirectories, or you could leave folders untouched and just delete files. For that, there are fields isFile and isDirectory
I have a ApplicationData.json file which includes some data used by my application.
The file is created before the app starts (manually) and it will never be deleted.
Sometimes, I need to override it's data by recreate the file with the updated data
.
In addition, I have more files which are generated on runtime.
I want all files to be reachable outside from my application manually.
In which path should I use while read & write to them?
Where should I locate my ApplicationData.json file before the app starts using Android Studio files explorer?
LibGDX: I have game-data files created at runtime for debugging purposes (a replay system). The files are stored in Gdx.files.local() whether on desktop or android. Now I want to copy the ones that were created on android so I can debug them on desktop.
Running Gdx.files.getLocalStoragePath() on android returns /data/user/0/com.[my domain].[my app]/files/. Using Windows Explorer I do not see my app's folder in /data/user/0, or anything else for that matter. So private storage indeed it is, but how nonetheless can I get hold of these files, without root if possible?
The solution may be manual copy or in code, whatever works. Just to note, the file names are unknown without seeing the files first. They were named using current date-time. The extension is known, though.
EDIT
I discovered Android Studio's Device File Explorer. I connected my device, tried to see inside my app folder and app data folder, both showing 'Operation not permitted'.
So to put the question in simpler words, is rooting the phone really the only way for developers to see the files created by their apps?
Or is there a magical gate somewhere known only to select few zen masters who guard the secret through the generations? Because I sure ain't finding it.
I'm not sure that there is a way to write changes in the system file without having root access but you can read them. According to this Blog, You can access those files and put it in your desktop. You can download RAR app from googleplay.
I am wondering if Shared Preference is a clean way to do what I am trying to accomplish. I am building an application where I need to have the ability to allow a 3rd party to pre-setup the application on the phone prior a user using it. I figured one way of doing this would be for the 3rd party to supply a Shared Preference XML file and for the application to attempt to read it at start up. If there is no custom file provided the application will start in default conditions.
I understand that this can be done using a regular file as well and I could just read and parse through a file, I am just wondering if Shared Preference is the clean way of doing this.
I am still somewhat new to Android Development so I also welcome better ideas of accomplishing this.
Thank you
Once the the app is installed on a device you will not have permissions to write to any of the app's folder. You will need the app itself to install the configuration file when it is started up.
This would be to read the configuration file, which can be a properties file, and have the app write or copy the values to the sharedpreferences.
To have the app get the properties file, it could be done by downloading the file from a server or even reading it from the ExternalFiles folder of the device (For the second alternative you will need to set the corresponding permissions in the manifest, and also request permissions at runtime for local storage).
The app, upon startup, will have to check if it has been initialized with the properties file (which can be be a flag in sharedpreferences) and if not try to get hold of the properties file to do the setup).
I'm working on an Android library that's meant to be used by multiple applications. The library needs to save data to a file that can be accessed by any of these applications.
Let's say I have two applications that use this library:
package com.example.app1
package com.example.app2
And that my library is under
package com.library.sdk
When the library running under app1 tries to save a file to internal storage, it is saved under com.example.app1. So if app2 wants to get access to that file, it needs to look under com.example.app1 using a ContentProvider, for example. The problem is that if app1 is uninstalled, the data saved in the file also vanishes.
Is there no way to let the library save the file to its own internal storage (i.e. under com.library.sdk)? I tried, but seem to get access violations. But shouldn't this be possible given that the library is it's own packaged project/jar?