Reputation: 5
I am new to android programming and I am working on my first application. The application needs to be able to read and write to a txt file on a networked computer. My application has buttons that are going to control different things and the file is going to contain the states of my toggle buttons (0 for off, 1 for on). I don't know if this is even possible and everywhere I have looked only discusses reading from the phone. I need the file on the computer because the computer needs to access the state changes as well for its own interface.
Upvotes: 0
Views: 49
Reputation: 3366
We don't usually provide written code in SO, but there are exceptions like this that I have similar code ready :)
You need to have a web server running on your computer(Windows: XAMPP, Mac: MAMP or XAMPP, Linux: Apache(or httpd on non-debian based distros. Available via package manager of your choice))
And then write a simple PHP script to write and read from the file (PHP Files and I/O).
After you did it only thing that remains, is to access the file from your phone.. There are lots of tutorials on the web on connecting Android and PHP. But I like this one better (How to connect Android with PHP, MYSQL.
And, (Just because I'm too generous :p), here is the source code to one of my programs that does nearly the same thing and was built by the help of the tutorials above: Feniix on Github !
Upvotes: 1