<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Loading a TPK file from assets folder in ArcGIS Runtime SDK for Android Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/loading-a-tpk-file-from-assets-folder/m-p/1521565#M6225</link>
    <description>&lt;P&gt;To package a small TPK file (Tile Package) with your Android app and reference it for use with ArcGISLocalTiledLayer, you need to follow these steps:&lt;/P&gt;&lt;P&gt;1. **Place the TPK File in the Assets Folder:**&lt;BR /&gt;- Copy your TPK file to the `assets` folder of your Android project. If the `assets` folder doesn't exist, create it under `src/main/`.&lt;/P&gt;&lt;P&gt;2. **Reference the TPK File in Code:**&lt;BR /&gt;- Use the `AssetManager` to access the TPK file from the assets folder.&lt;/P&gt;&lt;P&gt;3. **Use the TPK File with ArcGISLocalTiledLayer:**&lt;BR /&gt;- You'll use the path to the TPK file relative to the `assets` folder to create an `ArcGISLocalTiledLayer`.&lt;/P&gt;&lt;P&gt;Here's a basic example of how to do this in your Android code:&lt;/P&gt;&lt;P&gt;```java&lt;BR /&gt;// Import necessary ArcGIS classes&lt;BR /&gt;import com.esri.arcgisruntime.mapping.view.MapView;&lt;BR /&gt;import com.esri.arcgisruntime.mapping.ArcGISMap;&lt;BR /&gt;import com.esri.arcgisruntime.mapping.ArcGISLocalTiledLayer;&lt;BR /&gt;import com.esri.arcgisruntime.mapping.Basemap;&lt;/P&gt;&lt;P&gt;// Inside your Activity or Fragment&lt;BR /&gt;@Override&lt;BR /&gt;protected void onCreate(Bundle savedInstanceState) {&lt;BR /&gt;super.onCreate(savedInstanceState);&lt;BR /&gt;setContentView(R.layout.activity_main);&lt;/P&gt;&lt;P&gt;// Initialize the MapView&lt;BR /&gt;MapView mapView = findViewById(R.id.mapView);&lt;/P&gt;&lt;P&gt;// Load the TPK file from the assets folder&lt;BR /&gt;String tpkPath = "file:///android_asset/your_tile_package.tpk"; // Replace with your TPK file name&lt;/P&gt;&lt;P&gt;// Create the ArcGISLocalTiledLayer using the TPK file path&lt;BR /&gt;ArcGISLocalTiledLayer tiledLayer = new ArcGISLocalTiledLayer(tpkPath);&lt;/P&gt;&lt;P&gt;// Create an ArcGISMap and set the tiled layer as the base map&lt;BR /&gt;ArcGISMap map = new ArcGISMap(new Basemap(tiledLayer));&lt;/P&gt;&lt;P&gt;// Set the map to the MapView&lt;BR /&gt;mapView.setMap(map);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;@Override&lt;BR /&gt;protected void onPause() {&lt;BR /&gt;super.onPause();&lt;BR /&gt;mapView.pause();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;@Override&lt;BR /&gt;protected void onResume() {&lt;BR /&gt;super.onResume();&lt;BR /&gt;mapView.resume();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;@Override&lt;BR /&gt;protected void onDestroy() {&lt;BR /&gt;super.onDestroy();&lt;BR /&gt;mapView.dispose();&lt;BR /&gt;}&lt;BR /&gt;```&lt;/P&gt;&lt;P&gt;### Key Points:&lt;BR /&gt;- **Asset Path:** Use `"file:///android_asset/your_tile_package.tpk"` to reference the file from the assets folder.&lt;BR /&gt;- **ArcGISLocalTiledLayer Constructor:** The constructor takes the path to the TPK file as a string.&lt;/P&gt;&lt;P&gt;Make sure you have the necessary permissions and that your project is set up to include the ArcGIS Runtime SDK for Android. Also, ensure the TPK file is correctly named and located in the `assets` folder.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Aug 2024 15:12:12 GMT</pubDate>
    <dc:creator>BrahimDiaz</dc:creator>
    <dc:date>2024-08-14T15:12:12Z</dc:date>
    <item>
      <title>Loading a TPK file from assets folder</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/loading-a-tpk-file-from-assets-folder/m-p/490106#M3393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Suppose that I have a very small (1-2MBs) TPK file that I want to package along with the released APK, how can I reference it from raw or assets folder? What string should I pass for the ArcGISLocalTiledLayer's constructor to display it on to the map?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2016 07:03:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/loading-a-tpk-file-from-assets-folder/m-p/490106#M3393</guid>
      <dc:creator>JasonChristian</dc:creator>
      <dc:date>2016-11-30T07:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Loading a TPK file from assets folder</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/loading-a-tpk-file-from-assets-folder/m-p/490107#M3394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Do you know the way for use the tpk on android external storage?&lt;/P&gt;&lt;P&gt;You can copy this tpk from asset to external folder and after use as tile layer.&lt;/P&gt;&lt;P&gt;be satisfied?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2016 03:31:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/loading-a-tpk-file-from-assets-folder/m-p/490107#M3394</guid>
      <dc:creator>JinYingMin1</dc:creator>
      <dc:date>2016-12-02T03:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Loading a TPK file from assets folder</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/loading-a-tpk-file-from-assets-folder/m-p/1521565#M6225</link>
      <description>&lt;P&gt;To package a small TPK file (Tile Package) with your Android app and reference it for use with ArcGISLocalTiledLayer, you need to follow these steps:&lt;/P&gt;&lt;P&gt;1. **Place the TPK File in the Assets Folder:**&lt;BR /&gt;- Copy your TPK file to the `assets` folder of your Android project. If the `assets` folder doesn't exist, create it under `src/main/`.&lt;/P&gt;&lt;P&gt;2. **Reference the TPK File in Code:**&lt;BR /&gt;- Use the `AssetManager` to access the TPK file from the assets folder.&lt;/P&gt;&lt;P&gt;3. **Use the TPK File with ArcGISLocalTiledLayer:**&lt;BR /&gt;- You'll use the path to the TPK file relative to the `assets` folder to create an `ArcGISLocalTiledLayer`.&lt;/P&gt;&lt;P&gt;Here's a basic example of how to do this in your Android code:&lt;/P&gt;&lt;P&gt;```java&lt;BR /&gt;// Import necessary ArcGIS classes&lt;BR /&gt;import com.esri.arcgisruntime.mapping.view.MapView;&lt;BR /&gt;import com.esri.arcgisruntime.mapping.ArcGISMap;&lt;BR /&gt;import com.esri.arcgisruntime.mapping.ArcGISLocalTiledLayer;&lt;BR /&gt;import com.esri.arcgisruntime.mapping.Basemap;&lt;/P&gt;&lt;P&gt;// Inside your Activity or Fragment&lt;BR /&gt;@Override&lt;BR /&gt;protected void onCreate(Bundle savedInstanceState) {&lt;BR /&gt;super.onCreate(savedInstanceState);&lt;BR /&gt;setContentView(R.layout.activity_main);&lt;/P&gt;&lt;P&gt;// Initialize the MapView&lt;BR /&gt;MapView mapView = findViewById(R.id.mapView);&lt;/P&gt;&lt;P&gt;// Load the TPK file from the assets folder&lt;BR /&gt;String tpkPath = "file:///android_asset/your_tile_package.tpk"; // Replace with your TPK file name&lt;/P&gt;&lt;P&gt;// Create the ArcGISLocalTiledLayer using the TPK file path&lt;BR /&gt;ArcGISLocalTiledLayer tiledLayer = new ArcGISLocalTiledLayer(tpkPath);&lt;/P&gt;&lt;P&gt;// Create an ArcGISMap and set the tiled layer as the base map&lt;BR /&gt;ArcGISMap map = new ArcGISMap(new Basemap(tiledLayer));&lt;/P&gt;&lt;P&gt;// Set the map to the MapView&lt;BR /&gt;mapView.setMap(map);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;@Override&lt;BR /&gt;protected void onPause() {&lt;BR /&gt;super.onPause();&lt;BR /&gt;mapView.pause();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;@Override&lt;BR /&gt;protected void onResume() {&lt;BR /&gt;super.onResume();&lt;BR /&gt;mapView.resume();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;@Override&lt;BR /&gt;protected void onDestroy() {&lt;BR /&gt;super.onDestroy();&lt;BR /&gt;mapView.dispose();&lt;BR /&gt;}&lt;BR /&gt;```&lt;/P&gt;&lt;P&gt;### Key Points:&lt;BR /&gt;- **Asset Path:** Use `"file:///android_asset/your_tile_package.tpk"` to reference the file from the assets folder.&lt;BR /&gt;- **ArcGISLocalTiledLayer Constructor:** The constructor takes the path to the TPK file as a string.&lt;/P&gt;&lt;P&gt;Make sure you have the necessary permissions and that your project is set up to include the ArcGIS Runtime SDK for Android. Also, ensure the TPK file is correctly named and located in the `assets` folder.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2024 15:12:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/loading-a-tpk-file-from-assets-folder/m-p/1521565#M6225</guid>
      <dc:creator>BrahimDiaz</dc:creator>
      <dc:date>2024-08-14T15:12:12Z</dc:date>
    </item>
  </channel>
</rss>

