How to get the android String PATH to a file on drawable folder?

…衆ロ難τιáo~ 提交于 2020-01-11 13:32:09

问题


I'm trying to display locally stored maps with a api to show maps.

I need to know the string path to a map file stored on drawable folder, because i'm using a map api that needs to receive a string path, and my maps must be stored drawable folder (assets folder can't be used for this because the maps are higher than 1MB)

This is the code i'm trying, but this code is incorrect because the map is not being displayed:

        MapView mapView = new MapView(this);
        mapView.setClickable(true);
        mapView.setBuiltInZoomControls(true);
        String mapName="bremen";           
        String fileName = "android.resource://" + this.getPackageName() + "/drawable/"+mapName;
        //mapView.setMapFile("/sdcard/path/to/mapfile.map");
        mapView.setMapFile(fileName);             
        setContentView(mapView);

Wich is the correct string path file to the file bremen.map stored on my drawable folder?

Thanks


回答1:


I need to know the string path to a map file stored on drawable folder

There is no "string path to a map file stored on drawable folder", because there is no "drawable folder" except on your development machine.

Wich is the correct string path file to the file bremen.map stored on my drawable folder?

There is none.

Since MapView does not have setMapFile(), I am assuming you are using some third party implementation. If so, and that implementation is open source, modify it to support a Uri in addition to its existing support of a path.

Otherwise, copy the drawable resource to a file first, then supply a path to that file.



来源:https://stackoverflow.com/questions/8476452/how-to-get-the-android-string-path-to-a-file-on-drawable-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!