My getApplicationDocumentsDirectory() is returning me
/data/user/0/com.my.applicationname/app_flutter
While when using the device file explorer(and using "copy path" option),this directory comes up as
/data/data/com.my.applicationname/app_flutter
This is causing issues as when I try to play a file stored using above path prefix(using the uri as Uri.file(fileNameFromAbovePrefix), the file is not being found(whereas if I manually copy the path from device explorer and paste in Uri.file, it works).
My path_provider pluting version is ^2.0.1
So how do I get the path that actually works with uri(in a reliable way across all android devices)?
I have a resources folder amounting 2-3 GBs. I want to install the app with the obb in SD card directly as some users won't be having that much internal storage.
I am currently searching for the solution.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="preferExternal"
... >
I found out about this which installs the apk on external storage, but not the resources.
I am expecting that by default there must be an option in which apk is installed in the internal storage while the resources on the sd-card.
Well you first need the path the user wants the resources to be downloaded in.
Use AsyncTask to download zip file of the resource files
(You can also check this thread here for more details)
Unzip the files to the select path and then delete the the zip file
if you want the resources to be installed by default in the external sd card first check if they have one for it
if (android.os.Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED)) {
//Check for the file
File appFolder = new File(Environment.getExternalStorageDirectory() + File.separator
+ context.getString(R.string.app_name));
boolean exist = appFolder.exists();
}
then just set the path to it
if (exist == true){//your code here for the path}
though it is not wise as an external storage does not mean that it is a SD card
When I fresh install app, I notice most of the app will have a folder created in Internal Storage > Android > Data > com.example.package folder. For example its facebook app it will be something like com.facebook.xxxxx.
However, one of the project I involve recently, I notice there is no such app folder in the path Internal storage > Android > Data > (No packege folder).
In what scenario it won't create an app folder in the above path ? Because most of the app I debug run via android studio or install via apk file...Always have one app folder in the above location by default.
Because I want to write below file into getFilesDir(),
File file = new File(activity.getFilesDir(),imageFileName);
By using getFilesDir(), written file will go into Android > Data > Package folder > Files folder, most of the installed app have a package folder path in Android > Data > (Here). Today I realise one of the project I am doing now, it doesn't create such package folder. So, when I use getFilesDir() , those files will still be stored and created inside the mentioned path but it is invisible? Or Those files I create using getFilesDir() won't be created? Because as I mentioned this app doesn't create a package folder. Do I have to use makedir ? If yes what will be the checking ? if(!activity.getFilesDir(). exist())
File file = new File(activity.getFilesDir(),imageFileName);
//getFilesDir() normally is package folder Android > Data > (package folder*) > Files
I have tested and find out that if phone is having internal storage only (Not support SDCard) or maybe phone support external storage but don't have SDCard insert. App folder in this path by default won't be created (Android > Data > [App folder]), until I called (getExternalFilesDir(null) , "Example1") check its exists() and makedirs() if it doesn't exist, finally the app folder is created with a folder Example1 in this path Android > App > com.xxxxx.myapp > files > Example1.
However, why some sample app I create I never call getExternalFilesDir(null) or any File writing storage path but by default I can find my sample app path in Android > App > [Here].
Some app folder won't be created by default but until getExternalFilesDir(null) check exist and mkdirs then it become exist and created. Some app folder will be created when app is installed by default. How Android determine if the Android > App > App folder should be created and visible or created and make it invisible??
It makes me confuse. Some app will create app folder, some app wont create it by default when app is installed. Let's assume both app never call any File path create method. Just a very sample app I run using latest Android Studio to test something, it created package folder. The big project app is using old gradle settings and almost 5 years ago, the app by default won't create package folder until I call File(getExternalFilesDir(null), Example1) check if it exists and it doesn't then mkDirs(), package folder become created and visible.
How SY MY told you need to check if phone is having internal storage only (Not support SDCard) or maybe phone support external storage but don't have SDCard insert. App folder in this path by default won't be created. And how he checked you shoud make if statement. So... you can paste this code in your project:
File file = new File(getExternalFilesDir(null),fileName);
if (!file.exists()&&file.mkdirs()){
File file1 = new File(getFilesDir(), fileName);
}
fileName it is a String varable with txt foramt:
private String fileName = "list.txt";
I've created an app which reads a text file created by an installed app. The location of this file is located at: This PC\Galaxy S4\Phone\veryfit2.2\file.txt.
I tried to get access to this file using Environment and getBaseContext(), but in both cases, it didn't help. How can I access the text file?
Here's the folder directory:
I want to know if it's possible to access a .apk file from an installed application on a device (android), via its package Name in as3/air?
Right now I have an ANE file which helps me to get packageName (ex: com.somesite.someApp or air.myApp), I want to copy the .apk file (its byteArray), is this possible in as3/air or is there any available ANE file to do this?