How do I create an android app version of an existing PHP/MySQL application

  • Thread starter Thread starter AC Question
  • Start date Start date
A

AC Question

I have created a web application with PHP language and MySQL database which is already live. What I want to do now is to create and app version of the application using the same MySQL database and the PHP language.

What should be my approach and how do I go about?

Thank you
 
A web page to run on a phone? Or the client to access your site?

1. (website on the phone) You'll be using SQLite, not SQL (there are slight differences). You;ll be rewriting the page in Java (which I wouldn't want to do, but people have).

2. (client) Just write an app in Java that connects to your page and accesses the right things on the page. (The site has to be written to be accessed by an app.)
 
You can use the web view approach that is the app will open the webpage of you PHP without having to write it in java for the app.
For example java web view containers code will help you display your website or PHP page inside you app and not in the smartphone web browser.
Example code (main activity, android xml):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/urlContainer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
--------------------------------------------------------------------
Java code for the web view function:
public class WebViewActivity extends Activity
{
private WebView webView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);

webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new MyWebViewClient());

String url = "http://THELOCATIONYOURPHPORWEBSIDE.com";
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
}

private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
 

Members online

Forum statistics

Threads
955,878
Messages
6,965,982
Members
3,163,414
Latest member
dsfcdfcfdfc