Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Writing to text file on android phone?

Author
Message
2D Analyst
AGK Developer
20
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 30th Oct 2012 22:33
When I'm testing the game on Window 7, it loads/saves fine.

When I'm testing the game on Android OS 2.3 using the .apk file, the game can read the file, but can't write anything to it. Do I need to set a certain permission? I've already included the following:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>


Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 30th Oct 2012 23:07
I have no trouble with the file creation/writing in Android 3.2 and Android 4.1.

How do you know that you are not writing to the file?

If you are expecting the original file to change, it won't. When AppGameKit opens a file for writing, it does it in the sand boxed area, not the original media directory.

On my two devices, since I don't have an SD card inserted (Toshiba 7" Thrive Android 3.2) or available (Nexus 7 Android 4.1), I cannot find the files that are created or updated. But I know they exist because my app can find them.

Cheers,
Ancient Lady
AGK Community Tester
2D Analyst
AGK Developer
20
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 30th Oct 2012 23:14
I know it's not writing to the file because when the app loads, it open the file and reads the default value, which is 11. This means stage 1-1. Hm...maybe I should try to delete the file each time and then create a new one using the same file name.
2D Analyst
AGK Developer
20
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 31st Oct 2012 05:31
Okay, I figured out the issue. When I was testing my app, my USB cable was connected to the laptop and prevented the phone to save to the SD card.

I guess the text file is saved to SD card? Will it work for devices without SD Cards such as kindle fire?
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 31st Oct 2012 15:16
On Android files are now saved to the app data folder, which is hidden by the OS and will work on any device.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 31st Oct 2012 16:29
Also, I believe, once you've run the app once via the USB cable, it should remain installed on the device and be available after that. I think is the case. I haven't been able to run via the USB cable on any device for a long time. There is something buggy on my computer and I don't have the time to figure it out. I put the apks where I can download them on a local web site (available only in my house).

I know running an iOS app from Xcode leaves the app fully functional on the iOS device after it is disconnected.

Cheers,
Ancient Lady
AGK Community Tester
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 31st Oct 2012 17:06
Quote: "I believe, once you've run the app once via the USB cable, it should remain installed on the device and be available after that"


Correct, deploying from eclipse or copying using USB storage leaves the app on the device.
2D Analyst
AGK Developer
20
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 1st Nov 2012 19:37
@Paul Johnston

That's great. Will it work for devices with an SD card slot, but no SD card inserted? Most users will have SD card on SD card slot, but not all.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Nov 2012 20:43
Quote: "Most users will have SD card on SD card slot, but not all. "

I fall into that category. I haven't bothered to get a micro SD card for my Toshiba 7" Thrive. And the Nexus 7 doesn't come with an SD card slot.

Cheers,
Ancient Lady
AGK Community Tester

Login to post a reply

Server time is: 2024-11-24 01:33:16
Your offset time is: 2024-11-24 01:33:16