Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8118041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:21:36+00:00 2026-06-06T04:21:36+00:00

Here is my problem. I am trying to store data from my web app

  • 0

Here is my problem. I am trying to store data from my web app locally in an HTML5 database. Thing is, the database I try to open with my javascript returns null.

Here is the Android code:

public class NotepadActivity extends Activity {
WebView main_view = null;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //Get rid of the android title bar
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);

        main_view = (WebView) findViewById(R.id.main_webview);
        WebSettings settings = main_view.getSettings();

        settings.setJavaScriptEnabled(true);
        settings.setDatabasePath("/data/data/"+this.getPackageName()+"/databases/");
        settings.setDomStorageEnabled(true);

        main_view.loadUrl("file:///android_asset/index.html");

        main_view.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return false;
            }
            @Override
            public void onReceivedError(WebView view, int errorCod,String description,    String failingUrl) {
                Toast.makeText(NotepadActivity.this, "Error: " + description , Toast.LENGTH_LONG).show();
            }   
        });

        main_view.setWebChromeClient(new WebChromeClient() {
               public void onConsoleMessage(String message, int lineNumber, String sourceID) {
                 Log.d("Notepad", message + " -- From line "
                                 + lineNumber + " of "
                                 + sourceID);
              }
        });
     }

     public void onExceededDatabaseQuota(String url, String
            databaseIdentifier, long currentQuota, long estimatedSize, long
            totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
                        quotaUpdater.updateQuota(estimatedSize * 2);
            } 
}

And the relevant JavaScript:

     /* DB and result values */
    DB_name: "NotepadDB",
    DB_version: "1",
    DB_displayName: "Notepad Database",
    DB_sizeEstimate: 5 * 1024 * 1024,
    DB: null,

 ....



    /* Open a connection to the DB (or create if it doesn't exist) */
    openConnection: function() {
        App.log("App > DB > openConnection > Attempting to access database");
        App.val.DB = window.openDatabase(App.val.DB_name, App.val.DB_version, 
                        App.val.DB_displayName, App.val.DB_sizeEstimate, App.DB.initializeDatabase);
    },

    /* Only called when the database is initially created */
    initializeDatabase: function(database) {
        App.val.DB = database;

        //Create the required table
        App.val.DB.transaction(
            function (tx) {tx.executeSql('CREATE TABLE ' + App.schema.tableName + ' (' + App.schema.ID+ ' int unique, ' + App.schema.title + ' text, ' + App.schema.content + ' text, ' + App.schema.date + ' datetime)',
                [],
                function (tx, res) {
                    App.log("App > DB > intializeDatabase > Table Created Successfully");
                    App.DB.loadAllNotes();
                },
                function (tx, err) {
                    App.log("App > DB > intializeDatabase > ERROR - Table creation failed - code: " + err.code + ", message: " + err.message);
                    App.error("Unable to create database. Please try again later.");
                });
            }
        );
    },

    loadAllNotes: function() {
        if(App.val.DB != null) {
            //Do some stuff
        } else {
            App.log("App > DB > loadAllNotes > Database was NULL");
        }
    }

In my LogCat log I am seeing
App.log(“App > DB > loadAllNotes > Database was NULL”);
is executing.

Is there something I am missing here? Why is the database null?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:21:40+00:00Added an answer on June 6, 2026 at 4:21 am

    Solved it. The problem was I overlooked the following code:

         public void onExceededDatabaseQuota(String url, String
            databaseIdentifier, long currentQuota, long estimatedSize, long
            totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
                        quotaUpdater.updateQuota(estimatedSize * 2);
            } 
    

    This function should be within the main_view.setWebChromeClient(new WebChromeClient() { function, as it needs to override. D’oh!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to store data in created SQLite database. Here is the code
Here is a problem I am trying to solve: I have an irregular shape.
Here's my problem - I'm trying to access a session namespace across actions .
Here's my problem: I'm trying to set up a simple mobile contact form with
I'm trying to solve the problem here but I don't know why my code
I have an interesting problem here I've been trying to solve for the last
I am stuck with a small problem here.. What i am trying to do
I'm having a hard time trying to create a XmlRepository. The problem here I
Here's my problem. I'm currently trying to develop a .Net Compact Framework 2.0 application
So Here is the Problem, I am trying to get that circle to align

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.