java.lang.IllegalArgumentException:无效的列_data

时间:2018-04-07 04:05:58

标签: android

#!python2

import timeit

runs = 100
totalTime = 0.0; average = 0.0
testTimes = []

for i in range(runs):
    startTimer = timeit.default_timer()

    # >>>>> code to be tested goes here <<<<<

    endTimer = timeit.default_timer()

    timeInterval = endTimer - startTimer
    testTimes.append(timeInterval)
    totalTime += timeInterval

    # running below statement causes each run longer to complete
    # print '\n', '%1.4f' % timeInterval + ' seconds'

print
print '   Total time:', '%1.4f' % totalTime + ' seconds'
print 'Shortest time:', '%1.4f' % min(testTimes) + ' seconds'
print ' Longest time:', '%1.4f' % max(testTimes) + ' seconds'
print ' Average time:', '%1.4f' % (totalTime / runs) + ' seconds'

这是我的代码我试图从内容URI中获取VCf文件路径,当我尝试使用此函数获取文件路径然后我得到

  

java.lang.IllegalArgumentException:无效的列_data

fun convertUriToPath(context: Context, contentUri: Uri): String {
        var cursor: Cursor? = null
        try {
            val proj = arrayOf(MediaStore.Images.Media.DATA)
            cursor = context.getContentResolver().query(contentUri, proj, null, null, null)
            val column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)
            cursor.moveToFirst()
            return cursor.getString(column_index);
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }

如何解决这个问题?

0 个答案:

没有答案