1

I am developing an app with html5 pages locally stored in the assets folder. I have included a database with some php scripts, is it still possible to run in WebView?

2
  • php scripts? what you mean? Commented Sep 1, 2014 at 18:46
  • At the moment am developing database using php and mySql, planning on integrating it with the Html. Commented Sep 1, 2014 at 18:54

2 Answers 2

2

for using database in webView you have two ways:

1) use localStorage that you should handle it by javaScript

2) use java database,for that you need javaScriptInterFace() that provide you a bridge between javaScript and java class. and create java database then put your data in it or read from it

see this link it will help you-(this link show you how use java database like browser localStorage)

Sign up to request clarification or add additional context in comments.

3 Comments

Any links to javaScript tutorial for developing database or better, a demo?
I add link,check it please
Thanks, will check out the all the options.
0

No not at all you can not run a php in a webview it can understand only html ,CSS and JavaScript just like a browser.

Suggestion 1:

If you want to build a HTML page using your local database you could do that using java no need of php.

Just fetch the data from db then build HTML page by concatenating java strings with the data,HTML mark up,CSS and javascript then load the resulting HTML page in webview

If you want to access Java function from JavaScript you could use addjavascriptinterface of java.

The java function can be anything like a function that inserts or updates data into local dB or a function that returns a data from local db

It can also produce dynamic html content locally jus like a dynamic web language like php,classic asp etc..

Suggestion 2:

If you want to do it using php then you have to host it in the internet server along with db and load the page URL in webview

2 Comments

Ok, now how do i create a database and also be able to get data from it.
In android you could use cursors to load data from local db.In android we would use sqlite instead of Mysql.you can easily create sqlie db.just Google how to create local sqlite db ? How to consume add update data in android ? Its that simple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.