Android App: how to choose the installation folder?


I wrote an Android App in Delphi.

I noticed the some applications are installed directly under root directory e.g. /sdcard/AnkiDroid or /sdcard/doubleTwist.
However my app is installed somewhere else (I think /sdcard/Android/data).

How can I change it? Or if I can't how can I make the installation make a folder in the root directory?
I need the user to copy a file there so as my app would parse it.

Thank you very much!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sinisa VukSoftware architectCommented:
I think that there is no way to install anywhere but /sdcard/Android/data. Even this apps (doubleTwist? ..) are locate there but use folders as you noticed to keep some data....
And why you need separate folder for your app?
Member_2_7965240Author Commented:
I need the users to copy files in that directory so as my app would parse it.
Most users don't have much experience in copying files so I want to make things easier for them (not to find a directory which is hidden at first sight).
Sinisa VukSoftware architectCommented:
Then create folder from your app and look for it when need it... Let folder be empty (without installation files) and user will not be able to delete your essential app/data/files.
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Member_2_7965240Author Commented:
How can I create a folder from my app? If I know well, Android doesn't allow it or am I wrong?

Thank you.
Sinisa VukSoftware architectCommented:
1. you can extract root part out of TPath.GetSharedMusicPath and concatenate your folder or
2. use very useful functions collections from here  or here and make something like this:
uses System.IOUtils, FlyFilesUtils;
  sSDCard: String;
  sSDCard := GetExternalStoragePath;  //GetSDCardPath;
  ForceDirectories(TPath.Combine(sSDCard, 'MyAppFolder'));

Open in new window

Member_2_7965240Author Commented:
Sorry for the late reply.

I tested your code but at compile I get [DCC Fatal Error] FlyFilesUtils.pas(360): F2613 Unit 'Androidapi.JNI.Environment' not found.
I use Delphi Seattle.

it stops here:

{$IF CompilerVersion >= 27.0} // >= XE6
//  FMX.Helpers.Android,
{$IF CompilerVersion < 28.0} // < XE7

Thank you very much.
Sinisa VukSoftware architectCommented:
Those unis are in FlyFiles folder... Just add them (one by one) to project (Project menu -> Add to Project ...) when compile fails.
I've tested this on Tokyo.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Member_2_7965240Author Commented:
One more problem
I got this error message:
[DCC Error] FlyFilesUtils.pas(531): E2003 Undeclared identifier: 'EncodePath'

This is the code snippet. Obviously Delphi Seattle doesn't contain EncodePath, But what should I change it to?

{$IF CompilerVersion >= 29.0} //  XE8
   AURL := URL.Trim;
   Protocol := '';
   AIndex := AURL.IndexOf('//');
   if AIndex > 0 then
     Protocol := AURL.Substring(0, AIndex + 1); // has /
     AURL := AURL.Substring(AIndex + 1); // has /
   Result := Protocol + TNetEncoding.URL.EncodePath(AURL);  
   Result := TIdURI.URLEncode(Result);

Thank you.
Sinisa VukSoftware architectCommented:
Sorry, don't have Seattle to test, but here is what you can:
- use some text find tool (wincommander, ransec,...) and look for .pas files in Embarcadero (xe10) install folder for text EncodePath
- it is possible that function exists in different unit other than System.NetEncoding
- change it in uses if you find it ....

-if all fails... then change few lines from:
{$IF CompilerVersion >= 29.0}

Open in new window

{$IF CompilerVersion >= 31.0}

Open in new window

and this way you will use replacement (old) function ...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.