1

SQL データベースにアクセスする PhoneGap アプリケーションを Android にインストールしています。アプリケーションをアンインストールしてから再インストールしようとすると、データベース ファイルにアクセスできないというセキュリティ エラーが表示されます。アプリ/設定からこのデータベース ファイルを削除すると、アプリを再インストールでき、問題なく動作します。

アプリのアンインストール時にデータベースを自動的に削除して、自分 (または別のユーザー) が [設定] に移動せずに再インストールできるようにしたいと考えています。

これを行う方法のアイデアはありますか?

4

2 に答える 2

1

エラーが発生したときの LogCat データは次のとおりです。この問題とは無関係だと思われるものをいくつか省略しました。何も見逃していないことを願っています。

11-27 18:10:52.859: I/dalvikvm(32482): Could not find method android.webkit.WebView.<init>, referenced from method org.apache.cordova.CordovaWebView.<init>
11-27 18:10:52.859: W/dalvikvm(32482): VFY: unable to resolve direct method 3200: Landroid/webkit/WebView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V
11-27 18:10:52.859: D/dalvikvm(32482): VFY: replacing opcode 0x70 at 0x0001
11-27 18:10:52.859: D/dalvikvm(32482): VFY: dead code 0x0004-005b in Lorg/apache/cordova/CordovaWebView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V
11-27 18:10:52.898: I/CordovaLog(32482): Changing log level to DEBUG(3)
11-27 18:10:52.898: I/CordovaLog(32482): Found preference for useBrowserHistory=true
11-27 18:10:52.898: D/CordovaLog(32482): Found preference for useBrowserHistory=true
11-27 18:10:52.898: I/CordovaLog(32482): Found preference for exit-on-suspend=false
11-27 18:10:52.898: D/CordovaLog(32482): Found preference for exit-on-suspend=false
11-27 18:10:52.898: D/JsMessageQueue(32482): Set native->JS mode to 2
11-27 18:10:52.906: D/DroidGap(32482): DroidGap.init()
11-27 18:10:52.906: D/CordovaWebView(32482): >>> loadUrl(file:///android_asset/www/index.html)
11-27 18:10:52.906: D/PluginManager(32482): init()
11-27 18:10:52.914: D/CordovaWebView(32482): >>> loadUrlNow()
11-27 18:10:52.914: D/DroidGap(32482): Resuming the App
11-27 18:10:52.921: D/SoftKeyboardDetect(32482): Ignore this event
11-27 18:10:52.953: D/DroidGap(32482): onMessage(onPageStarted,file:///android_asset/www/index.html)
11-27 18:10:52.953: D/SoftKeyboardDetect(32482): Ignore this event
11-27 18:10:52.960: I/gralloc(520): Allocated 0x660072 size 6488161
11-27 18:10:52.992: D/SoftKeyboardDetect(32482): Ignore this event
11-27 18:10:53.015: D/szipinf(32482): Initializing inflate state
11-27 18:10:53.015: D/szipinf(32482): Initializing zlib to inflate
11-27 18:10:53.023: D/szipinf(32482): Initializing inflate state
11-27 18:10:53.023: D/szipinf(32482): Initializing zlib to inflate
11-27 18:10:53.039: D/szipinf(32482): Initializing inflate state
11-27 18:10:53.039: D/szipinf(32482): Initializing inflate state
11-27 18:10:53.039: D/szipinf(32482): Initializing zlib to inflate
11-27 18:10:53.039: D/szipinf(32482): Initializing zlib to inflate
11-27 18:10:53.164: I/ActivityManager(520): Displayed com.example.ezbrzy_homework_planner/.EzBrzy_Main: +407ms
11-27 18:10:53.398: D/dalvikvm(520): GC_CONCURRENT freed 1451K, 27% free 12851K/17543K, external 9751K/11799K, paused 3ms+8ms
11-27 18:10:54.054: D/Cordova(32482): onPageFinished(file:///android_asset/www/index.html)
11-27 18:10:54.054: D/DroidGap(32482): onMessage(onNativeReady,null)
11-27 18:10:54.054: D/DroidGap(32482): onMessage(onPageFinished,file:///android_asset/www/index.html)
11-27 18:10:54.070: I/Database(32482): sqlite returned: error code = 14, msg = cannot open file at source line 25467
11-27 18:10:54.085: D/DroidGap(32482): onMessage(networkconnection,wifi)
11-27 18:10:54.093: D/DroidGap(32482): onMessage(spinner,stop)
11-27 18:10:54.093: I/gralloc(520): Allocated 0x660072 size 6488161
11-27 18:10:54.234: I/Database(32482): sqlite returned: error code = 23, msg = not authorized
11-27 18:10:54.304: D/dalvikvm(32482): GC_EXTERNAL_ALLOC freed 595K, 44% free 3534K/6279K, external 2755K/2773K, paused 30ms
11-27 18:10:54.328: I/gralloc(520): Allocated 0x660072 size 6488161
11-27 18:10:55.539: I/gralloc(520): Allocated 0x660072 size 6488161
11-27 18:10:56.062: D/DroidGap(32482): onMessage(spinner,stop)
11-27 18:10:57.164: I/Database(32482): sqlite returned: error code = 1, msg = no such table: assignments
11-27 18:10:57.218: I/gralloc(520): Allocated 0x660072 size 6488161
11-27 18:10:58.414: I/gralloc(520): Allocated 0x660072 size 6488161

データベース名を別のものに変更するだけで問題なく動作します。今、私はデバイス上のアプリデータを消去することさえできず、古い名前を再度実行することさえできません(droid razr上で)...

于 2012-11-28T01:17:15.510 に答える
0

SQLiteを使用していると思いますが、一度使用しましたが、アプリケーションをiosに移植する際に問題があり、Phonegapが非常に使いやすいこの種のデータベースを使用しています。

http://docs.phonegap.com/en/2.2.0/cordova_storage_storage.md.html#ストレージ

そして、次のクエリでデータベースを削除できます。

db = window.openDatabase("TSSE", "1.0", "TSSE_DB", 200000);
db.transaction(populateDB, errorCB, successCB);
function populateDB(tx) {
   tx.executeSql('DROP TABLE IF EXISTS DB_name');
   tx.executeSql('CREATE TABLE IF NOT EXISTS DB_name (id, name, password, money)');
}
于 2012-11-20T04:48:43.373 に答える