User Tag List

Results 1 to 3 of 3

Thread: Making Fusion-generated files on Android devices readable in other Fusion apps?

  1. #1
    Clicker Fusion 2.5Android Export Module

    Join Date
    Feb 2014
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Making Fusion-generated files on Android devices readable in other Fusion apps?

    Hi All,

    My name is Ceri. I had KnP and TGF(1) a long time ago and recently came across the MMF2 demo and decided to get back into making my own games. I recently bought Fusion 2.5 and the Android Exporter. After a bit of head scratching, I managed to get it all working and can now make simple apps that run on a phone, which is great.

    One thing that I have been stuck on for a few days now is as follows:

    I need (reasons are very complex and longwinded, but it is necessary for what I want to do!) to be able to have two separate Fusion applications that read/write to a common file. Think of it conceptually as the old separate "settings" applications you used to get with DOS games that would write to a config that the main "game" application would then be able to query.

    In apps I make on the PC, this is easy enough as I stipulate a file path in a .ini object and that's where it gets written. I can then reference the same file from another application.

    When I test the same app on an Android device (Samsung Desire S phone in this instance), the writing to a file and remembering settings seems to work within an application. The problem is in getting the second application to acknowledge the existence of the file from the first application.

    This is compounded by the fact that I am not familiar with the folder structure of the phone itself, so even if I knew where to specify the paths, I'm not sure what I would set them to.

    If at all possible, I would really like to avoid having to write the files concerned to external storage like an SD card. What I would ideally like is:
    \applicationFolderOnPhone\Ceri's App1\settings.config
    to be readable by both 'Ceri's App1' and 'Ceri's App2'/.

    Many thanks in advance for any guidance you can offer and I look forwards to participating in the community here.

  2. #2
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleInstall Creator Pro

    Join Date
    Dec 2010
    Location
    United Kingdom
    Posts
    960
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Ceri, welcome to the forums!

    In order to retrieve paths, you'll first need the Android object present in the frame. There's two conditions:
    • DataStorageDirectory$( "Android object" ) -- which is internal to the phone and out of the user's hands (unless they are root of course) for your application only.
    • ExternalStorageDirectory$( "Android object" ) -- which is external and most likely the SD card.

    It works by specifying the expression and then + "nameoffile.ini" or + "folder/anotherfolder/nameoffile.ini" -- adding a slash at the start will not work. If you ever encounter a crash with files, it's generally because the file name is invalid or the folder structure hasn't been created.

    You should note that Android is Linux, and Linux uses a forward slash for its filesystem ("/") as opposed to Windows using a backwards slash ("\") when using directories.

    I had a peak at /data/data/com.myapp.name/shared_prefs (internal) and found the data for my own application:
    An INI file [user.settings] isn't actually saved in the INI format on Android, it's an XML file [MMF_data_data_com.myapp.name_filesuser.settings_server.xml] which contains the INI in XML. This might be a problem when it comes to referencing file names/paths, especially if it's not stored in /data/data/com.myapp.name/ on other Android devices.

    I'm not 100% certain, but Android's filesystem permissions may forbid other apps from reading/writing to other app's data (unless root) but I have not tested this myself.

    Writing to external storage may be the safest way in order for apps to share data with Fusion.

    Here's a tip: You can make the files "hidden" on the file system by adding a dot (".") in front of the file name. Eg ".settings.config" On Linux/Android, this indicates it's a hidden file and won't show up on file browsers (unless the option is checked to show this) -- if the device was plugged in to, say... Windows, this file would be visible.

    You can use the expression ExternalStorageDirectory$( "Android object" ) + DataStorageDirectory$( "Android object" ) which will store the data externally to the SD Card and then the ./Android/data/com.yourappname.here/ folder, which may a possibility as long as you know the application's package name or use a directory both apps can share.

    I hope this somewhat helps.

  3. #3
    Clicker Fusion 2.5Android Export Module

    Join Date
    Feb 2014
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent, exactly what I was after. Thank you very much for the comprehensive answer lh37.

    The application is for an augmented reality game I play with friends and we have android devices dedicated solely to the purpose of playing this game (all of which are under my control), so if rooting them is necessary, I will probably be able to do so.

    I will have root round (no pun intended) on the Android filesystem based on the above and try to locate the file concerned, if it's not possible and I don't manage to root them, it's only 6 devices so about £30 for micro SD cards.

Similar Threads

  1. New to Fusion 2.5 / Android Exporter
    By Spyhunter in forum Fusion 2.5
    Replies: 2
    Last Post: 23rd January 2014, 09:53 PM
  2. Replies: 1
    Last Post: 18th January 2014, 09:32 PM
  3. Fusion 2.5 box 2D physics not compatible with android?
    By foyzul2002 in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 14th December 2013, 12:21 AM
  4. Fusion 2.5 and Exporters (Android/iOS/HTML5)
    By Koji_Kabuto in forum Fusion 2.5
    Replies: 0
    Last Post: 12th December 2013, 10:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •