6

I have a button which when pressed opens twitter login page in a webview (as an activity). i'm using twitter4j version 2.2.6. the problem is this- when i click on the emulator or my samsung glaxy 2 it works perfectly witout any bugs, but when i click the button on my samsung galaxy 3 GT-I9300 (and my friends same phone) i get the following exception:

android.database.sqlite.SQLiteException: no such table: password: , while compiling: SELECT username, password FROM password WHERE (host == ?) at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) at android.database.sqlite.SQLiteCompiledSql.(SQLiteCompiledSql.java:68) at android.database.sqlite.SQLiteProgram.compileSql(SQLiteProgram.java:143) at android.database.sqlite.SQLiteProgram.compileAndbindAllArgs(SQLiteProgram.java:361) at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:127) at android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:94) at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:53) at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47) at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1684) at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1569) at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1525) at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1605) at android.webkit.WebViewDatabase.getUsernamePassword(WebViewDatabase.java:990) at android.webkit.BrowserFrame.handleMessage(BrowserFrame.java:589) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:950) at java.lang.Thread.run(Thread.java:856)

the webview is an activity (extends Activity) i have plenty of free space at the point of crash:

total- 12187213824 free- 4315947008

my configuration at the crash:

FlipFont=0
compatScreenHeightDp=546
compatScreenWidthDp=320
compatSmallestScreenWidthDp=320
fontScale=0.93
hardKeyboardHidden=HARDKEYBOARDHIDDEN_YES
keyboard=KEYBOARD_NOKEYS
keyboardHidden=KEYBOARDHIDDEN_NO
locale=en_US
mcc=425
mnc=1
navigation=NAVIGATION_NONAV
navigationHidden=NAVIGATIONHIDDEN_YES
orientation=ORIENTATION_PORTRAIT
screenHeightDp=615
screenLayout=SCREENLAYOUT_SIZE_NORMAL+SCREENLAYOUT_LONG_YES
screenWidthDp=360
seq=46
smallestScreenWidthDp=360
textLayoutDirection=0
touchscreen=TOUCHSCREEN_FINGER
uiMode=UI_MODE_TYPE_NORMAL+UI_MODE_NIGHT_NO
userSetLocale=false

device features:

android.hardware.wifi
android.hardware.location.network
android.hardware.nfc
android.hardware.location
android.hardware.sensor.gyroscope
android.hardware.screen.landscape
android.hardware.screen.portrait
android.hardware.wifi.direct
android.hardware.usb.accessory
android.hardware.bluetooth
android.hardware.touchscreen.multitouch.distinct
android.hardware.microphone
android.hardware.sensor.light
android.hardware.camera.autofocus
android.software.live_wallpaper
android.hardware.camera.flash
android.hardware.telephony
android.software.sip
android.hardware.touchscreen.multitouch.jazzhand
android.hardware.sensor.barometer
android.hardware.usb.host
android.hardware.touchscreen.multitouch
android.hardware.sensor.compass
android.hardware.faketouch
android.hardware.camera
com.sec.feature.minimode
android.software.sip.voip
android.hardware.sensor.proximity
android.hardware.location.gps
android.hardware.telephony.gsm
android.hardware.camera.front
com.nxp.mifare
android.hardware.touchscreen
android.hardware.sensor.accelerometer
glEsVersion = 2.0

ENVIRONMENT:

getAndroidSecureContainerDirectory=/mnt/asec
getCloudStorageDirectory=/mnt/sdcard/cloud
getCloudStorageDirectoryPath=/mnt/sdcard/cloud
getDataDirectory=/data
getDownloadCacheDirectory=/cache
getExternalStorageAndroidDataDir=/mnt/sdcard/Android/data
getExternalStorageDirectory=/mnt/sdcard
getExternalStorageDirectoryUsbHost=/mnt/sdcard/Storages/usb
getExternalStorageState=mounted
getRootDirectory=/system
getSecureDataDirectory=/data
getSystemSecureDirectory=/data/system
isEncryptedFilesystemEnabled=false
isExternalStorageEmulated=true
isExternalStorageRemovable=false

Permissions:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.GET_TASKS"/>

In the webview i didnt made any sqllite transaction or nothing involved.

see my answer about this line

I'm not a root user (meaning i have the write rights)

the code involving the webview is:

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    try{
                    requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.twitter);
        mIntent = getIntent();
        String url = (String)mIntent.getExtras().get("URL");
        WebView webView = (WebView) findViewById(R.id.webview);

        WebSettings settings = webView.getSettings();

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

        settings.setJavaScriptEnabled(true);
        settings.setAllowFileAccess(true);
        settings.setSaveFormData(true);
        settings.setSavePassword(true);
            webView.setWebViewClient( new WebViewClient()
            {
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url)
                {
                    ...
                    return false;
                }
            });
            webView.loadUrl(url);
         }catch(Exception e){
            e.printStackTrace();
         }


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

         quotaUpdater.updateQuota(204801); 
    } 

I've found this links that has some similarity:

I've looked on too many threads for a long week and i'm pretty frustrated about it

does anyone have any ideas? thanks

Community
  • 1
  • 1

2 Answers2

1

as it turns out i had this two lines somewhere else in the code:

context.deleteDatabase("webview.db");
context.deleteDatabase("webviewCache.db");

this lines where supposed to clear the caching for my webview, but this lines only worked on previous devices, in the galaxy 3 and maybe other devices as it turns out, the webview when initiated is not creating this databases again so the sqlite exception was because it really didn't have a table...

need to be careful with that- the line i wrote was misleading:

"In the webview i didn't made any sqllite transaction or nothing involved"

  • I have the exact same problem without any use for sqllite too, but I didn't make anything special with the cache!! & don't know what to look for now! – AbdelHady Dec 22 '16 at 16:31
0

This crash is difficult to reproduce, but I was getting the exact same exception (even mentioning "no such table: password") and I could reproduce it by going to an activity, then to a 2nd activity, and then opening a WebView in a dialog, displaying HTML containing the following form element:

<input type="password" name="pword" id="pword">

Removing that type="password" from that form element prevented it from crashing.

The WebView attempts to save passwords for later use, in a sqlite db. I can't say for sure, but I imagine this is not desirable behavior for most developers, so if you wanted, you can turn this feature off by calling the following on the WebView's WebSettings instance:

myWebView.getSettings().setSavePassword(false);

This answer might also shine some light on this issue: Memory leak in WebView

They point out another solution to this, which is:

webView = new WebView(getApplicationContext());
Community
  • 1
  • 1
ubzack
  • 1,878
  • 16
  • 16