问题列表 - 第33503页

随机异常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万
查看次数

34
推荐指数
5
解决办法
3万
查看次数

PHP删除第一个零

想要删除所有0放在某个变量的开头.

一些选择:

  1. 如果$var = 0002,我们应该剥离第一000($var = 2)
  2. 如果var = 0203410我们应该删除第一个0($var = 203410)
  3. 如果var = 20000- 什么都不做($var = 20000)

解决办法是什么?

php formatting string-formatting zero number-formatting

17
推荐指数
5
解决办法
4万
查看次数

如何隐藏控制台窗口?

问题:我有一个不应该看到的控制台程序.(它重置IIS并删除临时文件.)

现在我可以设法在开始后立即隐藏窗口,如下所示:

static void Main(string[] args)
{
    var currentProcess = System.Diagnostics.Process.GetCurrentProcess();
    Console.WriteLine(currentProcess.MainWindowTitle);

    IntPtr hWnd = currentProcess.MainWindowHandle;//FindWindow(null, "Your console windows caption"); //put your console window caption here
    if (hWnd != IntPtr.Zero)
    {
        //Hide the window
        ShowWindow(hWnd, 0); // 0 = SW_HIDE
    }
Run Code Online (Sandbox Code Playgroud)

问题是这显示了一秒钟的窗口.是否有控制台程序的构造函数,我可以在窗口显示之前隐藏它?

第二个:

我用

[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
Run Code Online (Sandbox Code Playgroud)

而且我不喜欢它里面的32.没有DllImport有没有办法做到这一点?
一种.NET方式?

.net c# vb.net console winapi

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

使用c#写入XML

如何使用c#创建具有此格式的xml文件?

<?xml version="1.0" encoding="utf-8" ?>
<wrap>
  <content>
    <title>
      WHAT ARE ROLES?
    </title>
    <text>
        Roles are security based permissions that can be assigned to registered user of the site. Users can have any number of role based security permissions that the administrator deems appropriate. Certain parts of the application may have security permissions assigned to them to make the information they contain available only to those users with the required permisions.
    </text>
  </content>
  <content>
    <title>
      CREATE A ROLE
    </title>
    <text>
        To …
Run Code Online (Sandbox Code Playgroud)

c# xml

0
推荐指数
1
解决办法
296
查看次数

致命错误LNK1112:模块机器类型'x64'与目标机器类型'X86'冲突

我正在使用CUDA(VC++,Visual studio 2008sp1)来调试FEM程序.由于cuda的不足,该程序只能在Win32平台上运行.我认为链接的库文件都是在x86平台上编译的,但是当我编译它时,我收到错误消息"致命错误LNK1112:模块机器类型'x64'与目标机器类型'X86'冲突".

我试图将平台转换为x64,但它没有用.请告诉我:什么是"模块机器类型"什么是"目标机器类型"?我怎么能克服它?

visual-c++-2008 visual-c++

171
推荐指数
7
解决办法
30万
查看次数

枚举Mathematica中的所有分区

喜欢Select[Tuples[Range[0, n], d], Total[#] == n &],但速度更快?

更新

以下是3个解决方案及其时间图,IntegerPartitions后跟Permutations似乎是最快的.分别为递归,FrobeniusSolve和IntegerPartition解决方案的时间分别为1,7和0.03

partition[n_, 1] := {{n}};
partition[n_, d_] := 
  Flatten[Table[
    Map[Join[{k}, #] &, partition[n - k, d - 1]], {k, 0, n}], 1];
f[n_, d_, 1] := partition[n, d];
f[n_, d_, 2] := FrobeniusSolve[Array[1 &, d], n];
f[n_, d_, 3] := 
  Flatten[Permutations /@ IntegerPartitions[n, {d}, Range[0, n]], 1];
times = Table[First[Log[Timing[f[n, 8, i]]]], {i, 1, 3}, {n, 3, 8}];
Needs["PlotLegends`"];
ListLinePlot[times, PlotRange -> All, 
 PlotLegend -> {"Recursive", "Frobenius", "IntegerPartitions"}]
Exp /@ …

wolfram-mathematica

6
推荐指数
2
解决办法
508
查看次数

强制下载文件与PHP给出空文件

最终目标是让用户下载.csv文件.现在我只是试着下载一个简单的文本文件:test.txt.这个文件中唯一的东西是"test"这个词.

这是files_to_download.php的HTML代码

Test file: <a href='test.php?file=test.txt'>Test.txt</a>
Run Code Online (Sandbox Code Playgroud)

test.php的代码:

if(!(empty($_GET["file"])))
{
    $file_name = $_GET["file"];
    $path = "path/to/file";
    $fullPath = $path . $file_name;

    if(ini_get('zlib.output_compression'))
      ini_set('zlib.output_compression', 'Off');

    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-Disposition: inline; attachment; filename=\"$file_name\"");
    header("Content-Type: text/plain");
    header("Content-Transfer-Encoding: binary");
    readfile($fullPath);
}
Run Code Online (Sandbox Code Playgroud)

我尝试过上面标题的变体,添加更多内容并删除其他标题.以上似乎是本网站最常推荐的.

我也试过改变

header("Content-Type: text/plain");
Run Code Online (Sandbox Code Playgroud)

header("Content-Type: text/csv");
Run Code Online (Sandbox Code Playgroud)

并得到相同的结果:空.txt或.csv文件.

从服务器直接打开文件(文件浏览器)时,文件不为空.我已经检查了文件的权限,它们都是644,所以整个世界至少可以读取文件.该目录是777.

是否有我需要指定的Apache服务器上的配置可能不是,或者我错过了上面的内容.

谢谢你的期待!

php file download

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

c#中可读的良好可读名称

我在FsUnit中读到以下是F#中有效的方法/类名:

[<TestFixture>] 
type ``Given a LightBulb that has had its state set to true`` ()=
   let lightBulb = new LightBulb(true)

   [<Test>] member test.
    ``when I ask whether it is On it answers true.`` ()=
       lightBulb.On |> should be True
Run Code Online (Sandbox Code Playgroud)

有没有办法在c#中使用这样的方法或类名?

c# f# unit-testing naming

3
推荐指数
1
解决办法
194
查看次数

类名宏

可能重复:C++中的
CLASS

您好,有没有办法获取类的名称类如__FUNCTION__的函数名?我唯一的想法是使用纯虚拟toString继承一些基类,并通过手工时间来定义名称.谢谢.

c++ macros class

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