• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How do I connect my android studio app to a remote SQL database (xampp))?

Hello,

I am creating an app that finds a piece of username data after a click of a button.

So far I have:

>>Installed and configured xampp
>>Portforwarded my router
>>set up an online webserver
>>Used PHP to create a database and implement it into the webserver.

Php code index.php
Code:
<?php
echo "<h1>Hello World</h1>";

$servername = "localhost";
$username = "root";
$password = "";
$db = "testDatabase";                
$table = "myGuests";       

$conn = new mysqli($servername, $username, $password);

if ($conn->connect_error) {
  die("Connection failed: <br>" . $conn->connect_error);
}
else {
    echo "Connected to MySQL successfully <br>";
}

$sql = "CREATE DATABASE $db";
if ($conn->query($sql) === TRUE) {
  echo "Database created successfully<br>";
} else {
  echo "Error creating database: <br>" . $conn->error;
}


$conn = new mysqli($servername, $username, $password, $db);
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

$sql = "CREATE TABLE $table (
                    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
                    usernameOut VARCHAR(50) NOT NULL,
                    passwordOut VARCHAR(50) NOT NULL,
                    reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
                    )";

if ($conn->query($sql) === TRUE) {
  echo "Table MyGuests created successfully<br>";
} else {
  echo "Error creating table: <br>" . $conn->error;
}

$sql = "INSERT INTO $table (usernameOut, passwordOut)
VALUES ('Admin', '1-password')";

if ($conn->query($sql) === TRUE) {
  echo "New record created successfully<br>";
} else {
  echo "Error: " . $sql . "<br>" . $conn->error;
}

$sql = "SELECT id, usernameOut, passwordOut FROM MyGuests";
$result = $conn->query($sql); // $result will be an array

if ($result->num_rows > 0) {
  while($row = $result->fetch_assoc()) {
  }
} else {
  echo "0 results";
}

$sql = 'DROP DATABASE testDatabase';
if ($conn->query($sql) === TRUE) {
  echo "Database deleted successfully<br>";
} else {
  echo "Error deleting database:<br> " . $conn->error;
}
$conn->close();

echo "The time is " . date("h:i:sa");
?>

I ran my public webpage and I know for sure the php code works and adds the data to the webserver. I am not sure how to make android studio grab the database information from the public website.
(https//PUBLICIPADRESS:8080)

Any links or tutorials on how to do this would be appreciated, Thanks!

- Denver

Need advice about being hacked

Thanks for the advice, I truly appreciate it! I don't mind losing all of my accounts honestly. I've already reset all my stuff and really kind of accepted the fact nothing I do or say is private. They use my phone line for something. It's crazy... I figure my only fix would be to find a hacker, but I just moved out here recently and sketched to give any one else access :/ I think the local police will think im nuts, but I'm thinking I should report it. What scares me is thinking they're going to get into my work computer. This will all come back to me... idk...

Apps FAILURE: Build failed with an exception.

Facing the below issue on my system after updating the android studio and all its plugins.

FAILURE: Build failed with an exception.

* What went wrong:
Could not create an instance of type org.gradle.plugin.management.internal.DefaultPluginResolutionStrategy.
&gt; com.google.common.collect.ImmutableList.builderWithExpectedSize(I)Lcom/google/common/collect/ImmutableList$Builder;

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

I tried with different solutions as mentioned below, but didn't get any success.
1. Invalidating cache and restart
2. Resetting Android Studio settings to default.
3. Uninstalling everything and re-installing.
4. Reverting to the previous version of android studio.

Please help me if anyone knows the solution.

Robo Defense

A Tips for those who had already passed Survival Mode and want to gain more reward points while extending their Max Level :

I find that you can set the level to your max level and then click Survival Mode and then pass it. The Max Level will extent to the next 10.

The good things of playing Survival Mode instead of the original normal level.
1. Easier building up your maze as the initial waves are low level.
2. Much higher reward points as the later waves are higher level, especially if you can save up and sell for more remaining money. The remain money bonus is amount * level (1000!) * 2. Of cause if your level is already near to 1000, it might turn out gain lesser reward points.
3. The game play is more consistent so you can test out different mix tower code and compare them more easily while extending your max level.

The game is out for 11 years but I just find and bought it for a month. Enjoyed it very much.

What app has a heart with a star in it for the notification icon?

My D-Bag (EX)boyfriend just flipped out at me over this icon, accusing me of nonsense about having dating app profiles..

It's ACTUALLY the icon for Rewarded Play. It's one of the multitudes of gaming apps that are currently being advertised EVERYWHERE, that give you points for usage time, that you can then trade in for various gift cards.

But hey, if you wanna get single fast, jumping to conclusions and making accusations is a good way to do it!

Switching "Obama" lifeline to LG Aristo

Thank you so much; I did wind up calling the Assurance Wireless people and was able to get a human being on the line, and for 5 dollars plus tax, I have a Unimax U69 3CL on the way...
The LG Aristo had a 15 digit serial number while the Assurance "Swap Phones" page said to enter the 11, 14 or 17 digit serial number of the new phone; that was the first clue that it might not work...
But, after having had bad experiences calling Assurance -long holds; barely intelligible English on the other end, with what I was saying echoing loudly about a second after I spoke; I was glad that a person answered on a quiet line. I decided to take advantage of their "free replacement" option (that I was eligible for because of how long I had suffered with the ANS UL40 (which is about the size of a small stack of playing cards) and so within 5 to 7 days, I'll have a phone that should work through their carrier, and on their network, and with their service.

S7 died in its sleep

We had very similar with my wife's S7 except it died when awake. In our case it stopped dead as she was trying to switch off bluetooth when she heard me driving up as she didn't want the phone to pair with the car. The phone showed absolutely no signs of life at all. There was no indication of charging. It didn't respond to press and hold power or power and vol-down or any of the other combinations of home key, vol-up, vol-down, power, plugging in cable etc that you read on the internet. It was dead as a post. She couldn't go long without the phone so we took it to an expert the next day who instantly diagnosed an internal hardware fault that he was unable to repair. It would need a mainboard repair or replace which would cost more than the phone was worth. So we replaced it (with a Samsung A71) and swapped over the SIM and SD and most of the data restored itself from cloud or SD.

The story doesn't end there... After a couple of days I tried charging again and the charging LED was lit, and charging graphics came up. I let it charge right up and it powered up OK but after a few minutes of frantically trying to upload the data that we lost, it died again. The back of the phone was warmer than it should be. I figured that whatever internal fault the mainboard had was causing it to heat up and discharge the battery too fast. So for my next attempt I put it in the freezer overnight. On next re-start, I put it into flight mode and only turned on wifi - needed to upload data. This time we recovered a few photos before it died again. After a few more attempts, I found that I could get all the lost photos off it by freezing it, charging it from frozen to about 30% then powering it up while still cold. I switched off all wireless functions then sat the back of the phone in ice water with a USB drive in the USB port and copied all the files we wanted directly to the USB drive. This was much faster than wifi and clearly wasn't taxing whatever part of the hardware was faulting and causing it to die. I think the ice water helped to keep it cool for longer operation but if I needed to do it again, I'd fashion a waterproof shield around the top half of the phone with aluminium foil and blu-tac so that more of the back of the phone could be submerged. As it was, I needed the USB port above water and if I let the top of the phone dip under the water, the wave of water would activate the swipe down from the top of the screen.

Our fall-back position would have been to send the phone away for a chip-out data recovery for which we were quoted $180NZD with no guarantee of success. This wasn't worth it for the data involved but we were happy to be able to recover what we wanted ourselves.

Good luck if you have the same issue - and try the same fix. Our new phone is setup much better for doing regular backups to the cloud.

Filter

Back
Top Bottom