小编Ran*_*ku'的帖子

随机异常android.database.sqlite.SQLiteException:无法打开数据库文件

我的应用程序使用未捕获的异常处理程序,在应用程序崩溃时将堆栈跟踪发送给我.我经常从随机用户那里得到这份报告.

我无法复制它,数据库的打开总是在我的情况下成功.这不是存储在外部SD卡上的数据库,只是打开的数据库SQLiteOpenHelper(context, "SomeName", null, someVersionCode).

你有这方面的经验吗?在打开数据库之前我可以检查哪些可能性?

谢谢!

android.database.sqlite.SQLiteException: unable to open database file
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
    at android.app.ActivityThread.access$2200(ActivityThread.java:119)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4363)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.sqlite.SQLiteException: unable to open database file
    at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
    at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1698)
    at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:739)
    at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:761)
    at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:754)
    at android.app.ApplicationContext.openOrCreateDatabase(ApplicationContext.java:476)
    at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:193)
    at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98)
Run Code Online (Sandbox Code Playgroud)

database sqlite android

23
推荐指数
2
解决办法
1万
查看次数

如何在C#中使用p/invoke将指针传递给数组?

示例C API签名:

void Func(unsigned char* bytes);

在C中,当我想将指针传递给数组时,我可以这样做:

unsigned char* bytes = new unsigned char[1000];
Func(bytes); // call
Run Code Online (Sandbox Code Playgroud)

如何将上述API转换为P/Invoke,以便我可以将指针传递给C#字节数组?

c c# api pinvoke

21
推荐指数
2
解决办法
3万
查看次数

如何在Android上获取CPU使用情况统计信息?

我想获得Android上的整体CPU使用率,类似于Windows的任务管理器.我可以解析topAndroid中包含的程序的输出,但如果有一个API调用做同样的事情,那就更好了.

有什么指针吗?

android processor cpu-usage performance-monitor

21
推荐指数
2
解决办法
4万
查看次数

从命令行(adb shell)查询Android内容提供程序

有一个命令可以根据意图启动一个活动:am start.还发送广播:am broadcast.

我想可能应该有一个shell命令来查询内容提供者,可能是这样的:

query content://com.myapp.authority/path --where 'column=?' --arg 1 --order 'column desc'
Run Code Online (Sandbox Code Playgroud)

或类似的.

有吗?

android adb android-contentprovider android-shell

21
推荐指数
1
解决办法
2万
查看次数

在build.gradle中使用CPU ABI拆分时,不考虑Android产品风格

我想根据http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits根据CPU ABI进行APK拆分,但是我想将APK拆分为一个某些产品的味道.

所以我的build.gradle文件有以下产品风格plainmarket.实际上我想在构建market风味时执行APK拆分.

android {
    productFlavors {
        plain {
        }
        market {
            splits {
                abi {
                    enable true
                    reset()
                    include 'armeabi', 'armeabi-v7a', 'x86', 'mips'
                    universalApk true
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

然而,当我调用gradle assemblePlainDebugassembleMarketDebug,他们都产生了多个APK.上面的配置有问题吗?

我正在使用com.android.tools.build:gradle:1.2.3.

android apk android-gradle-plugin android-productflavors

15
推荐指数
1
解决办法
1713
查看次数

工具的用途是什么:从向导创建DrawerLayout(使用NavigationView)时openDrawer ="start"?

在Android Studio中使用导航抽屉创建活动会导致其显示在XML代码中:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">
Run Code Online (Sandbox Code Playgroud)

如果我删除了tools:openDrawer="start"布局预览,导航抽屉将关闭而不是打开.

我认为这是一个替换属性,类似于android:text可以替换tools:text为在布局预览中放置一些占位符文本.但是当我将其更改为android:openDrawer或时app:openDrawer,无法编译应用程序,因为它们是未知属性.

所以我想知道tools:openDrawer它是如何工作的,以及是否记录在任何地方.

android android-studio navigation-drawer android-navigationview android-tools-namespace

15
推荐指数
2
解决办法
6511
查看次数

RMI服务器:rmiregistry或LocateRegistry.createRegistry

对于服务器端的RMI,我们需要启动rmiregistry程序,还是只需要调用LocateRegistry.createRegistry?如果两者都有可能,有哪些优点和缺点?

java rmi rmiregistry

13
推荐指数
1
解决办法
1万
查看次数

仅定位Android电子市场中的高分辨率(像素)设备

我想发布一个专门在800x480或更高屏幕上运行的应用程序.

我不希望拥有480x320,320x240等设备的用户从Android Market获取它.我该如何配置?

市场过滤器似乎有答案,但我仍然没有得到它.

android filter screen-resolution google-play

13
推荐指数
1
解决办法
2474
查看次数

如何在Kotlin中自定义Android Studio的导入顺序,以忽略它们是否为“静态”导入?

使用Android Studio 3.4.1中的“优化导入”,导入的顺序类似于此:

import com.walla.walla
import com.willy.willy
import org.koin.android.ext.android.get
import org.koin.androidx.viewmodel.ext.android.viewModel
import kotlin.concurrent.thread // <-- note this line
import kotlin.random.Random
Run Code Online (Sandbox Code Playgroud)

正如您在上面看到的,函数(在Java中也称为“静态”导入)导入类似于kotlin.concurrent.thread并且 kotlin.random.Random被置于其他导入之下。

它与Android Kotlin样式指南不一致:

将类,函数和属性的导入语句组合在一个列表中,并按ASCII排序。

我无法找到一种方法来实现Android Studio订单导入,无论导入是类还是函数。有没有这样做的选择?

import android kotlin android-studio

13
推荐指数
1
解决办法
488
查看次数

Log.e不会打印UnknownHostException的堆栈跟踪

调用Log.e(TAG, "some message", e)where e是a UnknownHostException,不会在logcat上打印堆栈跟踪.

android logcat

12
推荐指数
1
解决办法
683
查看次数