0

I am new to Android. I tried to open a file in internal storage.

The file is located in: mnt/sdcard/italy.sqlite. There are many solutions on the web, I tried some, but I am keeping get different errors..

First try:

String extStore = System.getenv("EXTERNAL_STORAGE"); 

File spatialDbFile = new File(extStore, "italy.sqlite");

I printed System.getenv("EXTERNAL_STORAGE"); , I got:

/sdcard

Second try:

File spatialDbFile = new File("mnt/sdcard/italy.sqlite");

This still doesn't work.

Could someone help me?

kevin
  • 309
  • 2
  • 12
  • 1
    External storage is defined as the public storage area accessible by all apps - meaning accessing EXTERNAL_STORAGE in the way you do accesses the shared storage internally on the device(meaning not external SD card). As for the output you get, I assume you actually have an SD card in the device. Further, I recommend you read [this answer by Commonsware](https://stackoverflow.com/a/5695129/6296561) – Zoe Jun 07 '17 at 19:07
  • "I tried to open a file in internal storage." -- that is not [internal storage](https://commonsware.com/blog/2014/04/07/storage-situation-internal-storage.html). That is [removable storage](https://commonsware.com/blog/2014/04/09/storage-situation-removable-storage.html). – CommonsWare Jun 07 '17 at 19:43

1 Answers1

-2

You should better check whether you have given permission to open file in internal storage at Manifest file. it will be like-

//Here is an example of the manifest file:

<?xml version="1.0" encoding="utf-8"?>

<manifest>

    <uses-permission />
    <permission />
    <permission-tree />
    <permission-group />
    <instrumentation />
    <uses-sdk />
    <uses-configuration />  
    <uses-feature />  
    <supports-screens />  
    <compatible-screens />  
    <supports-gl-texture />  

    <application>

        <activity>
            <intent-filter>
                <action />
                <category />
                <data />
            </intent-filter>
            <meta-data />
        </activity>

        <activity-alias>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </activity-alias>

        <service>
            <intent-filter> . . . </intent-filter>
            <meta-data/>
        </service>

        <receiver>
            <intent-filter> . . . </intent-filter>
            <meta-data />
        </receiver>

        <provider>
            <grant-uri-permission />
            <meta-data />
            <path-permission />
        </provider>

        <uses-library />

    </application>

</manifest>
Shawn Mehan
  • 4,513
  • 9
  • 31
  • 51