Android App: how to choose the installation folder?

Hello,

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!
Member_2_7965240Asked:
Who is Participating?
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?
0
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).
0
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.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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.
0
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;
...
var
  sSDCard: String;
begin
  sSDCard := GetExternalStoragePath;  //GetSDCardPath;
  ForceDirectories(TPath.Combine(sSDCard, 'MyAppFolder'));
end;

Open in new window

0
Member_2_7965240Author Commented:
Hello,
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:

uses
{$IFDEF ANDROID}
{$IF CompilerVersion >= 27.0} // >= XE6
  Androidapi.Helpers,
//  FMX.Helpers.Android,
{$ENDIF}
{$IF CompilerVersion < 28.0} // < XE7
  FMX.Helpers.Android,
{$ENDIF}
  Androidapi.Jni,
  Androidapi.JNI.Environment,
  Androidapi.JNI.StatFs,
  Androidapi.JNI.Stream2,
  Androidapi.JNI.ActivityManager,

Thank you very much.
0
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.
0

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
   begin
     Protocol := AURL.Substring(0, AIndex + 1); // has /
     AURL := AURL.Substring(AIndex + 1); // has /
   end;
   Result := Protocol + TNetEncoding.URL.EncodePath(AURL);  
{$ELSE}
   Result := TIdURI.URLEncode(Result);
{$ENDIF}

Thank you.
0
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

to
...
{$IF CompilerVersion >= 31.0}
...

Open in new window

and this way you will use replacement (old) function ...
1
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
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.