Applying a License

Loading the License file

In Aspose.Cells for Android via Java, the license can be embedded as a resource, or loaded from a stream:

  1. Put the license file at any location on /mnt/sdcard/.
  2. Create a stream that references file.
  3. Pass the stream (containing the license file) into the SetLicense method.

Java

 String dataDir = Environment.getExternalStorageDirectory().getPath() + "/";

// Create a stream object containing the license file

FileInputStream fstream = new FileInputStream(dataDir + "Aspose.Cells.Android.lic");

// Instantiate the License class

License license = new License();

//Set the license through the stream object

license.setLicense(fstream);

Applying a License from an Embedded Resource

To access the license as a resource by name from an Android package file:

  1. Add the license file as a resource to your application’s res/raw folder. The license file should be visible in the res/raw folder.
  2. Access/load the license from the resource with the following code sample.

Java

 License license = new License();

InputStream inputStream = getResources().openRawResource(R.raw.license);

license.setLicense(inputStream);